getting values from JSON.htm with dzVents script
Posted: Wednesday 10 May 2023 0:37
I have a 1000 liter hot water buffer tank where temperatures are measured at different heights.
With these temperatures I calculate a capacity number in the form of electrical power stored in a virtual device. When the entire vessel is at 80 degrees i consider it full, if full it contains about 50 kilowatts of heating power. So far no problem. I notice a daily loss of energy that i would like to compensate with electrical heating power from my solarpannels but how much to compensate i want to calculate.
Through my browser I can read the history of the daily highest and lowest value of this device in the past month:
http://192.168.178.2:7080/json.htm?type ... ange=month This outputs:
With these values I can then calculate a loss and a percentage, and with this data and other data I can then prepare an email which will be sent at the end of the day.
And this is where it goes weird, As a test i use a testscript trying to dump the json data in the log.
I'm running Domoticz on a Synology NAS in a Docker container, so I can't use 192.168.178.2 to request a JSON in a script.
Also not 127.0.0.1, because that is the loopback that Docker container uses at the outside of the container, so I searched further and found that Domoticz IN the container (probably) uses 127.17.0.2. Added this IP address to trusted networks just to be sure.
Docker container uses a bridge to share internal communications with the outside world, forwarding port 80 internally to port 7080.
this testscript runs without error messages but also does not display any data(debug-log gives:)
Now I do not know whether this is due to an error in the testscript, or whether this is due to the ip address used, or whether its possible to read data at all from a JSON.htm using a dzVents script, but i can't figure it out..
some help would be very welcome.
With these temperatures I calculate a capacity number in the form of electrical power stored in a virtual device. When the entire vessel is at 80 degrees i consider it full, if full it contains about 50 kilowatts of heating power. So far no problem. I notice a daily loss of energy that i would like to compensate with electrical heating power from my solarpannels but how much to compensate i want to calculate.
Through my browser I can read the history of the daily highest and lowest value of this device in the past month:
http://192.168.178.2:7080/json.htm?type ... ange=month This outputs:
- Spoiler: show
With these values I can then calculate a loss and a percentage, and with this data and other data I can then prepare an email which will be sent at the end of the day.
And this is where it goes weird, As a test i use a testscript trying to dump the json data in the log.
Code: Select all
return {
on = {
timer = {
'every minute'
}
},
logging = {level = domoticz.LOG_INFO},
execute = function(domoticz, triggeredItem)
local url = 'http://172.17.0.2:80/json.htm?type=graph&sensor=counter&idx=233&range=month'
domoticz.openURL({
url = url,
method = 'GET',
callback = function(response)
if (response.ok and response.status == 200) then
domoticz.log('Raw data: ' .. response.data, domoticz.LOG_INFO)
else
domoticz.log('Error opening url: ' .. url, domoticz.LOG_INFO)
end
end
})
end
}
Also not 127.0.0.1, because that is the loopback that Docker container uses at the outside of the container, so I searched further and found that Domoticz IN the container (probably) uses 127.17.0.2. Added this IP address to trusted networks just to be sure.
Docker container uses a bridge to share internal communications with the outside world, forwarding port 80 internally to port 7080.
this testscript runs without error messages but also does not display any data(debug-log gives:)
Code: Select all
dzVents: Info: ------ Start internal script: Script #2:, trigger: "every minute"
dzVents: Debug: OpenURL: url = http://172.17.0.2:80/json.htm?type=graph&sensor=counter&idx=233&range=month
dzVents: Debug: OpenURL: method = GET
dzVents: Debug: OpenURL: post data = nil
dzVents: Debug: OpenURL: headers = nil
dzVents: Debug: OpenURL: callback = function
dzVents: Info: ------ Finished Script #2
some help would be very welcome.