Upgrading an existing plugin device with new states

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
Forum rules
This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
User avatar
travisc
Posts: 346
Joined: Tue Sep 07, 2010 7:24 am
Location: Toronto, Canada
Contact:

Upgrading an existing plugin device with new states

Post by travisc »

Hi All,

Maybe someone can point me in the right direction on this. I've checked the docs and the forums and can't seem to find a solution. Though it's been a while since I've coded for Indigo so it may just be that I'm a little rusty. :)

I have a few plugins that I'd like to improve with new features. These improvements will need to add some states to the plugin's Indigo devices. I can't seem to find a way for the plugin to add the new states to the Indigo device automatically. The only way I've found is to double-click on the device and then dismiss the device dialog, then Indigo automatically adds the new states.

Is there a clean way for the plugin to check if a particular state exists in the device? And if not for it to call a method to tell Indigo to read the Devices.xml and add the new states?

I'm sure there's a simple solution here and I've just overlooked it.

Thanks!
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Upgrading an existing plugin device with new states

Post by jay (support) »

You can call this method:

Code: Select all

dev.stateListOrDisplayStateIdChanged()
on the device instance and it'll call getDeviceStateList() (and getDeviceDisplayStateId()) again - so if you added any states (or deleted them) then the device will be updated with the new state list.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
User avatar
travisc
Posts: 346
Joined: Tue Sep 07, 2010 7:24 am
Location: Toronto, Canada
Contact:

Re: Upgrading an existing plugin device with new states

Post by travisc »

Ahhh yes, that's perfect. I had a look through the plugin docs and device base class but didn't see that.

Thanks Jay!
Locked

Return to “Extending Indigo with Plugins and Python”