The Indigo 7 documentation says:
Enhanced plugin valuesDict handling so that plugin methods that return a valuesDict can modify key/value pairs in an instance's pluginProps attribute even if there are no UI <Field> nodes defined for those pairs inside the Devices.xml, Events.xml, etc.
So following on from this question and loosely related, using Indigo 7 I have tried the following code within a Button press callback method within a device config:
- Code: Select all
qwerty = {} # Also tried indigo.Dict() without success
qwerty['A'] = 'A'
qwerty['B'] = 'B'
valuesDict['qwerty'] = qwerty
valuesDict['abcdef'] = 'abcdef'
return valuesDict
When I subsequently save the config and then print the device to the Indigo log, the
qwerty field is missing but the
abcdef field is present. Indigo gives no indication/error as to why the
qwerty field is omitted.
I discovered that my code (in response to the initial question) wasn't working when I just ran it but confusingly was when I tested it in the debugger. I then realised that the difference was that in the debugger (as I was single stepping code) I was taking so long that the ConfigUI dialogue timed out and so the save didn't happen. I was updating the plugin props in the
closeDeviceConfigUi and then these were getting "nuked" when the
closeDeviceConfigUi returned to Indigo when it completed the update.
Hence thinking that I should use the ability to update valuesDict instead.
So what I am ideally looking to do is to update the pluginProps in the
closeDeviceConfigUi but if I can't then I can do it on a button press by updating the valuesDict if it is possible to define a dictionary to it. The fallback is that I can have a number of fields suffixed with 01, 02, 03, ... 27 (as I know the limit).