I am modifying a driver, and I am having trouble understanding attributes and values, specifically how I can set attributes and how i can type / modify and read values.
Specifically, I am working on a multizone audio device. I would like attributes
attribute "PowerOn", "boolean"
attribute "ZoneActive", "boolean"
I have then tried to set their values with
device.updateDataValue("PowerOn", true)
which gives an error as updateDataValue takes two string arguments.
I tried
device.updateDataValue("PowerOn", "true")
log.debug "PowerOn = ${device.currentValue("PowerOn")}."
def mydm = device.getData()
mydm.each { key, value ->
log.debug "Name: $key Value: $value"
}
which gives
"PowerOn = null."
"Name: PowerOn Value: true"
In this case it seems it creates a new "Value" "PowerOn" and sets its value to "true" but that is not the device attribute.
So my questions really are:
- What is the practical difference between attributes and values?
(when should I use one vs the other) - How can I set and read attributes?
- Can I get values that are not string data types.
Thanks for your help.