I would like to define custom states for a device depending the data it send through a serial port. For that, I decided to define a new property into pluginProps, which is a list containing all states keys. The method getDeviceStateList() just read this property and build an indigo.List() with all states.
First question : my approach is correct ?
The following code is the method analyzing data read from the serial port :
- Code: Select all
def updateDeviceStates(self, dev, tramesTeleinfo):
for element in tramesTeleinfo.items():
keyState = element[0]
valueState = element[1]
self.debugLog(u"Clé: " + keyState + ", valeur: " + valueState)
if not keyState in dev.states:
updatedPluginProps = dev.pluginProps
if not 'statesKeys' in updatedPluginProps:
updatedPluginProps[u'statesKeys'] = []
updatedPluginProps[u'statesKeys'].append(keyState)
indigo.server.log(u'StatesKeys after update :\n%s' % updatedPluginProps[u'statesKeys'])
dev.replacePluginPropsOnServer(updatedPluginProps)
dev.stateListOrDisplayStateIdChanged()
dev.updateStateOnServer(key=keyState, value=valueState)
It seems "updatedPluginProps[u'statesKeys'].append(keyState)" doesn't do anything ... The next line log the updatedPluginProps[u'statesKeys'] status, but the list is always empty ... What's my problem ?