Can a custom device support the device attribute "onState"?

Posted on
Sun Jun 14, 2020 6:46 pm
papamac offline
User avatar
Posts: 131
Joined: Jan 29, 2014

Can a custom device support the device attribute "onState"?

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?

Posted on
Sun Jun 14, 2020 7:04 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Can a custom device support the device attribute "onStat

Unfortunately, you are correct in your surmising of the issues: only sensor and relay device types have the onState attribute defined, and using <UiDisplayStateId> only works for the custom device class (not relay or sensor). We've had a few people run into this, or similar, snags so it is on the table for us to improve the behavior (no ETA but on my list).

You can extend the sensor device class with a custom state, like faultState, that you set to clear or fault, but it won't be visible in the device table under the main states column.

You might just want to call this API:

dev.setErrorStateOnServer(u"fault")

See this forum post for a description of its behavior.

Image

Posted on
Sun Jun 14, 2020 7:27 pm
papamac offline
User avatar
Posts: 131
Joined: Jan 29, 2014

Re: Can a custom device support the device attribute "onStat

Thanks Matt for the quick reply. I think that I will proceed with the Masquerade solution.

Take care,

David Krause aka papamac

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 18 guests