Page 1 of 1

Handling Device configuration changes

PostPosted: Sun Nov 03, 2013 6:51 pm
by decouto
Can someone tell me what the 'best' way to handle device configuration changes is?

When a user edits a device configuration, will the device have stopDeviceComm called before its properties are changed (due to the user edits). Or, do I need to somehow detect changes while the device is active, e.g via closedDeviceConfigUi. I've also seen mention of deviceUpdated(); is that something I need to worry about?

Motivating example is my alarm plugin which has zone devices; User an set the zone number on a device, and if they change the number I want to notice that and do the appropriate book-keeping int he plugin. But it seems it could get hairy with a few cases to handle.

Perhaps I can make it impossible for them to change the zone number once the device is created; what are the odds of that being successful or even a good idea?

thanks

Doug

Re: Handling Device configuration changes

PostPosted: Mon Nov 04, 2013 9:28 am
by matt (support)
Hi Doug,

In most cases you should be able to just define stopDeviceComm() and startDeviceComm(). The latter will be called on Indigo Server startup, and former on shutdown. They both will be called whenever a device plugin property is changed (most likely because the Config UI is closing down), so you can use them at bottlenecks for keeping the plugin back-end logic in sync.

deviceUpdated() is a lower-level hook that you can skip defining. Internally it ends up calling stop/startDeviceComm(). If you do override it, then it is important to call the parent method in your override or some of the higher level logic will drop out.

Re: Handling Device configuration changes

PostPosted: Mon Nov 04, 2013 11:58 am
by decouto
Thank you