local variable not updating until after script\working with json data
Posted: Sunday 23 December 2018 18:53
I am trying to get the RGB value of a dummy_color_switch.
The json value looks like this:
Color "{\"b\":255,\"cw\":0,\"g\":247,\"m\":3,\"r\":199,\"t\":0,\"ww\":0}"
in my dzvent script i would like to have 3 variables for Red\Green\Blue.
So from the wiki i get that i need to use domoticz.utils.fromJSON() and that i can then assign these 3 values so i made this script:
When i change the color on the switch, i dont see the new values but i see the old values from the previous change.
Is this the right way to get specific values from a json value?
How do i make this so these values are from the made change.
The json value looks like this:
Color "{\"b\":255,\"cw\":0,\"g\":247,\"m\":3,\"r\":199,\"t\":0,\"ww\":0}"
in my dzvent script i would like to have 3 variables for Red\Green\Blue.
So from the wiki i get that i need to use domoticz.utils.fromJSON() and that i can then assign these 3 values so i made this script:
Code: Select all
return {
on = {
devices = {
'color_switch'
}
},
execute = function(domoticz, device)
myColor = domoticz.utils.fromJSON(device.color) -- also tried this with 'local myColor'
print(myColor.r)
print(myColor.g)
print(myColor.b)
end
Is this the right way to get specific values from a json value?
How do i make this so these values are from the made change.