I'm using a custom device in an alarm system plugin that has an "onOffState" in its states list. I would like to include the sensor device feature of the simple "onState", allowing other plugins to reference dev.onState instead of dev.states[u'onOffState']. I tried to include "SupportsOnState" with a value of true in the device XML. This adds the key/value pair u'SupportsOnState: True to dev.pluginProps, but does not add additional attributes to the device object.. Is there any way to add the "onState" attribute to the device short of redefining it as a sensor device?
I did try the approach of defining a sensor device XML with added custom states (including a "displayState") to support the alarm system plugin. I included the usual declaration <UiDisplayStateId>displayState</UiDisplayStateId> to the XML, but it didn't work. It seems that a sensor device will only use the "onOffState" for its displayStateId, so I can't see the custom "Clear" and "Fault" states in the UI display.
So... I struck out on both approaches. The only other alternative is to use the Masquerade plugin to define new sensor devices that match the states of the custom devices. I avoided this somewhat obvious solution because it must be done for about 50 devices. Seemed tedious and complicated if there were simple coding alternatives.
Any thoughts?