Handling Device configuration changes

Posted on
Sun Nov 03, 2013 6:51 pm
decouto offline
Posts: 20
Joined: Apr 28, 2013

Handling Device configuration changes

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

Posted on
Mon Nov 04, 2013 9:28 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Handling Device configuration changes

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.

Image

Posted on
Mon Nov 04, 2013 11:58 am
decouto offline
Posts: 20
Joined: Apr 28, 2013

Re: Handling Device configuration changes

Thank you

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests

cron