kw123 wrote:How do I add a state to an existing device? ...
Coincidentally, I was only reading about this yesterday
Take a look at
Device Base Class Instance Methods.
There is a method
stateListOrDisplayStateIdChanged() which has the description
Plugins can subclass the method getDeviceStateList() to provide dynamic state list definition information. The default implementation provides a static solution by retrieving the device state list definition from the Devices.xml file. Likewise, the method getDeviceDisplayStateId() can be used to dynamically determine which device state should be displayed in the State column of the main device table UI. The problem is that the Indigo Server only calls getDeviceStateList() and getDeviceDisplayStateId() at very specific times, like when a plugin device dialog is dismissed. So, call stateListOrDisplayStateIdChanged() on the device instance you need refreshed at any time and Indigo will then automatically call your plugin's getDeviceStateList() and getDeviceDisplayStateId() methods (or use the base implementation of looking up the list from Devices.xml) and update the Indigo Server (and all clients). This is particularly useful for plugin updates that need to add new device states to existing device instances created by older versions. In this case, the plugin will need to update the device instances by calling stateListOrDisplayStateIdChanged(). A likely place to do this type of instance level upgrading is inside your plugin's deviceStartComm() method.
Hope this helps