Getting stuck, to get state information out of json (hue)
Posted: Saturday 19 January 2019 15:37
I got stuck with my dzvents scripts. I hope soomebody can help me.
Did a search on "hue" here of the forum, but the word is to small. With manual searching didn't found the answer.
What do i like to do: Read out the status of one single hue devices.
When running "http://192.168.xxx.xxx/api/xxxxxxxxxxxx ... x/lights/5" i get nice information, where i can find the imformation i am searching for, but how to get it out of there.
This is the information i get:
What is my dzvents scripts:
When running that script, i get the "name" as response, which is "keukenkast", that works.
But i would like to know how i can get the information from {"state":{"on"}}, which should be TRUE or FALSE
Does somebody know how to get this info out of the response?
Did a search on "hue" here of the forum, but the word is to small. With manual searching didn't found the answer.
What do i like to do: Read out the status of one single hue devices.
When running "http://192.168.xxx.xxx/api/xxxxxxxxxxxx ... x/lights/5" i get nice information, where i can find the imformation i am searching for, but how to get it out of there.
This is the information i get:
Code: Select all
{"state":{"on":false,"bri":203,"hue":7674,"sat":199,"effect":"none","xy":[0.5017,0.4151],"ct":443,"alert":"none","colormode":"xy","mode":"homeautomation","reachable":true},"swupdate":{"state":"readytoinstall","lastinstall":"2017-11-25T18:20:27"},"type":"Extended color light","name":"Keukenkast","modelid":"LLC020","manufacturername":"Philips","productname":"Hue go","capabilities":{"certified":true,"control":{"mindimlevel":40,"maxlumen":300,"colorgamuttype":"C","colorgamut":[[0.6915,0.3083],[0.1700,0.7000],[0.1532,0.0475]],"ct":{"min":153,"max":500}},"streaming":{"renderer":true,"proxy":true}},"config":{"archetype":"huego","function":"decorative","direction":"omnidirectional"},"uniqueid":"xx:xx:xx:xx:xx:xx:xx:xx-xx","swversion":"5.105.0.21169"}Code: Select all
return {
on = {
timer = {
'every 1 minutes'
},
httpResponses = {
'Light_Callback'
}
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.log('Timer event')
domoticz.openURL({
url = 'http://192.168.xxx.xxx/api/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/lights/5',
method = 'GET',
callback = 'Light_Callback',
})
end
if (item.isHTTPResponse) then
domoticz.log('HTTP reponse was ok')
if (item.statusCode == 200) and (item.isJSON) then
domoticz.log('JSON was detected')
local State = item.json['name']
domoticz.log('--------- ' .. State .. '---------')
end
end
end
}But i would like to know how i can get the information from {"state":{"on"}}, which should be TRUE or FALSE
Does somebody know how to get this info out of the response?