Some good questions. Could it be that device.deviceNetworkId is read-only? See: What Happened to deviceNetworkId?
To solve the problem of updated() running twice, I usually do something like this:
/**
* updated()
*
* Runs when the user hits "Done" from Settings page.
*
* Note: Weirdly, update() seems to be called twice. So execution is aborted if there was a previous execution
* within two seconds. See: https://community.smartthings.com/t/updated-being-called-twice/62912
**/
def updated() {
log.trace "updated():"
def cmds = []
if (!state.updatedLastRanAt || now() >= state.updatedLastRanAt + 2000) {
state.updatedLastRanAt = now()
// do stuff...
return response(cmds)
}
else {
log.trace "updated(): Ran within last 2 seconds so aborting."
}
}
Follow this thread to see if we ever get an answer as to why it runs twice… Updated() being called twice?
I’m pretty sure updated() is a supported method for device handlers as it’s the main way to process settings after they’ve been changed.