I have a "MyStrom" Switch with integrated Temp-Sensor. I would like to get that Data from the Switch and pass it to a Virtual Sensor in Domoticz.
MyStrom Switch API: https://api.mystrom.ch/#982cf1bb-c873-4 ... dfa51e1afe
I have created a Dummy and a Virtual Temperatur Sensor called "Temp Balkon"
Then i searched trough the wiki an came out with this Script below:
It doesn't give me an error in the log, but also the Temperatur does not get Updated it shows only 0°C.
The Output of the Integrated Sensor looks like this:
Code: Select all
{"measured":21.3125,"compensation":11,"compensated":10.3125}
Code: Select all
return {
on = {
timer = {
'every 5 seconds' -- just an example to trigger the request
},
httpResponses = {
'TempBalkon' -- must match with the callback passed to the openURL command
}
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'xxx.xxx.xxx.xxx',
method = 'GET /temp',
callback = 'TempBalkon', -- see httpResponses above.
})
end
if (item.isHTTPResponse) then
if (item.ok) then
if (item.isJSON) then
local TempBalkon = item.json.compensated -- just an example
-- update some device in Domoticz
domoticz.devices('TempBalkon').updatetemperatur(item.json.compensated)
end
else
domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
domoticz.log(item, domoticz.LOG_ERROR)
end
end
end
}
Thanks in Advance