Let me preface this by saying that I haven't found any other way to solve this problem, so if anyone has any ideas please let me know!
For my Insteon device configuration nodes, I have run into a situation where the only way I can figure out how to reliably keep NR config node settings in sync with the physical hardware settings is to programmatically trigger the update and deploy buttons with my own button. This totally not the right way to do it.
This would not be necessary if there was an onDeploy
callback that allowed me to write a block of client code for my config node that got executed when the user clicks the deploy button. This code block also needs to have the ability to throw an error that prevents the node's config from being written.
Some details of how the callback would be used in my node:
- User opens the device node config panel for a motion sensor (or any device, but motion sensor is a good example because its battery powered and not listening unless the user wakes it up)
- Changes are made to to the sensors settings (motion timeout duration for example)
- User clicks update to close the config panel
- User deploys
- onDeploy callback is fired
- callback issues ajax request to update the sensor
Now one of two things happens:
- Insteon library was able to write the new settings to the device
- Settings are re-read from the device (to verify) and sent back to the client
- Client writes verified settings to the config
- NR deploys and the
flows.json
file is written
Or:
- Insteon library times out because the motion sensor is not reachable
- ajax call reports failure, deployment of the config node is aborted (other nodes that succeed could deploy)
And for what it's worth, here's how I have worked around it by calling update and deploy
And here's a short video of the node in action with the above work around implemented.