I'm feeling like a real newbie right now so I'm hoping somebody can provide some clarification and/or direction.
As I understand it, valuesDict is generally used in various plugin callback methods to validate and possibly change UI values. It's very valuable in that changes can be made in various callbacks (menu change, button press, validation method, etc.) but the values only get written permanently as properties if the user does not cancel the configuration dialog. This is probably an oversimplification but hopefully works for this discussion.
Anyway, I'm working on a custom device plugin that gets values from the UI, and they are converted to device properties if the user does not cancel the configuration dialog. Pretty straight forward so far. However, in a button callback method, I'd like to create some 'properties' that are not part of the UI. These properties would also get permanently saved as device properties if the user does not cancel the configuration dialog. They would get discarded if the user cancels.
I though I could use valuesDict for this purpose, however, it doesn't seem to always work. For example, in the button callback method, I added a simple string to valuesDict that did not correspond to any UI element. As I hoped, it would get converted to a property when the configuration dialog was closed, but it was forgotten if the dialog was canceled. Yay.
The problem I ran into was trying to crate a more complicated variable type and save the value in valuesDict. Specifically, I want to create a list where each item in the list is a dictionary. When I create the list and add it to valuesDict, then return valuesDict, the list does not appear to actually get added. At first I thought this might a mutable vs. immutable issue, but I tried various workarounds with no avail.
First question: Can valuesDict be used in this way? Stated otherwise, can I randomly insert values of various types in valuesDict that would eventually get saved as device properties? I'm assuming no, but wanted to confirm.
Now here's where the newbie part comes in. I'd like to be able to maintain this list in a variable until the user either confirms or cancels the configuration dialog. At that point I can either write the variable as a device properly or just discard it if the user cancels, mimicking valuesDict functionality. I can't figure out where to create the variable so that it can be referenced by the various callback methods.
I thought about defining this in the plugin startup method, like I have with other global variables, but this variable is specific to the device instance, not the plugin.
Thoughts? Advice? Thanks!