- Code: Select all
Error in plugin execution UiAction:
Traceback (most recent call last):
File "plugin.py", line 2591, in deviceStateGenerator
TypeError: string indices must be integers
On this line:
- Code: Select all
id = valuesDict['thing']
I have confirmed that valuesDict['thing'] at that stage contains the expected value (an Indigo ID number for a device or variable). If I trap the TypeError and simply ignore it, the rest of the flow works as expected.
- Code: Select all
<Field id="thing" type="menu" defaultValue="None">
<Label>Source:</Label>
<List class="self" filter="" method="listGenerator" dynamicReload="true"/>
<CallbackMethod>deviceStateGenerator</CallbackMethod>
</Field>
<Field id="thingState" type="menu" defaultValue="None">
<Label>Text to chart:</Label>
<List class="self" filter="" method="deviceStateGenerator" dynamicReload="true"/>
</Field>
- Code: Select all
def deviceStateGenerator(self, filter="", valuesDict=None, typeId="", targetId=0):
indigo.server.log(u"deviceStateGenerator: {0}".format(valuesDict))
try:
id = valuesDict['thing']
return self.Fogbert.generatorStateOrValue(id)
except KeyError:
return [("Select a Source Above", "Select a Source Above")]
except TypeError:
pass
The valuesDict key appears to exist and have a valid value, so why the TypeError? Clearly, there's something I'm not seeing.