Store/Retrieve a Map in a Attribute via SendEvent

Yeah, if you need to store this in an attribute, I think that's what you'll have to do. Hubitat does have a documented JSON_OBJECT type for attributes, but when I retrieve it, all I get is a string as far as I can tell, so you'd have to re-convert it to a Map, List, or whatever data structure you're using to represent the data in Groovy. But you really only need an attribute if you need users of the device to be able to respond to events where these values change or for arbitrary apps to be able to access this data (e.g., as one might with lightEffects or supportedFanSpeeds, two JSON_OBJECT attributes I can think of).

If it's for internal use within your driver, the idea above of storing it to state should work just as well. State natively supports Maps and Lists, so you wouldn't have to do any work yourself. If the data never changes, you could also use something like a static field (@Field) to hold this data and refer to it in your own code as needed. Here's an example of that for the lightEffects attribute:

1 Like