- Posted on
Thu Dec 12, 2019 12:52 pm
-
FlyingDiver
offline
-
- Posts: 7189
- Joined: Jun 07, 2014
- Location: Southwest Florida, USA
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.