dynamic device states

Posted on
Thu Dec 12, 2019 11:51 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

dynamic device states

in a plugin:

Does anyone have an example of how to dynamically enable / disable / add / remove device states?

I learn better from copying / trying instead of trying to understand manuals

Any example highly appreciated


Karl

Posted on
Thu Dec 12, 2019 12:52 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: dynamic device states

Take a look at the code for the MQTT Shims plugin. Specifically the handling of the 'states_key' in the 'shimValueSensor' device type, starting around line 345. . That device will ready an arbitrary dict from the JSON data in an MQTT message and create states for each key in the dict.

There's also some trickery in the device type definition in Devices.xml. I have to keep a list of the states in a pluginProp, so I know when the state list has changed. the getStateList function returns the list saved in the pluginProp. The plugin defines the getDeviceStateList function to provide the modified state list to the server.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Dec 12, 2019 1:06 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: dynamic device states

Or the GhostXML plugin - whose only job is to dynamically maintain unknown states.


Sent from my iPhone using Tapatalk Pro

Posted on
Thu Dec 12, 2019 2:07 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: dynamic device states

Or the WeatherSnoop plugin (the WS3 agent device type)... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Dec 12, 2019 5:56 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: dynamic device states

thanks , good examples.

Karl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests