howartp wrote:However, yes it seems some work on robustness would come in handy; can I call updateStateListInIndigoTriggerUISoThatIt'sUpToDate() anywhere?
Indigo polls out of the plugin (by calling getDeviceStateList) the information both when the UI is first shown and then again upon selection of a popup in the state menu list. So the problem should only occur if those two calls (which should happen in a relatively short period of time from one another, unless the user leaves the dialog open a long time) return different data. It sounds like that is possible but based on your description unlikely, which is a bit puzzling.
Can you put some debug logging code in your plugin's getDeviceStateList() that dumps to the Event Log the result it is returning to Indigo? Maybe also cache off the value in the plugin then compare that to the currently returned value to see how often it really changes? Something like this (untested):
- Code: Select all
# put this in plugin init
self.lastReturnedStateList = None
# put in getDeviceStateList right before it returns
if self.lastReturnedStateList is not None and self.lastReturnedStateList != stateList:
indigo.server.log("state list changed")
indigo.server.log("old state list: %s" % unicode(self.lastReturnedStateList))
indigo.server.log("new state list: %s" % unicode(stateList))
self.lastReturnedStateList = stateList
return stateList
Then see if it logs that the state lists changed when (and only when) the bug in the UI happens?