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.

- buffervat.JPG (31.32 KiB) Viewed 682 times
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
- {
"CostEnergy" : 2200,
"CostEnergyR1" : 1100,
"CostEnergyR2" : 1100,
"CostEnergyT2" : 2200,
"CostGas" : 6218,
"CostWater" : 16473,
"Divider" : 1000.0,
"DividerEnergy" : 1000.0,
"DividerWater" : 1000.0,
"ValueQuantity" : "",
"ValueUnits" : "",
"result" :
[
{
"d" : "2023-04-08",
"u_max" : 2060.0,
"u_min" : 0.0
},
{
"d" : "2023-04-09",
"u_max" : 1690.0,
"u_min" : 0.0
},
{
"d" : "2023-04-10",
"u_max" : 2030.0,
"u_min" : 0.0
},
{
"d" : "2023-04-11",
"u_max" : 0.0,
"u_min" : 0.0
},
{
"d" : "2023-04-12",
"u_max" : 0.0,
"u_min" : 0.0
},
{
"d" : "2023-04-13",
"u_max" : 0.0,
"u_min" : 0.0
},
{
"d" : "2023-04-14",
"u_max" : 0.0,
"u_min" : 0.0
},
{
"d" : "2023-04-15",
"u_max" : 0.0,
"u_min" : 0.0
},
{
"d" : "2023-04-16",
"u_max" : 68230.0,
"u_min" : 0.0
},
{
"d" : "2023-04-17",
"u_max" : 67960.0,
"u_min" : 50070.0
},
{
"d" : "2023-04-18",
"u_max" : 50030.0,
"u_min" : 42100.0
},
{
"d" : "2023-04-19",
"u_max" : 42100.0,
"u_min" : 37100.0
},
{
"d" : "2023-04-20",
"u_max" : 37100.0,
"u_min" : 23870.0
},
{
"d" : "2023-04-21",
"u_max" : 23830.0,
"u_min" : 10570.0
},
{
"d" : "2023-04-22",
"u_max" : 10570.0,
"u_min" : 610.0
},
{
"d" : "2023-04-23",
"u_max" : 640.0,
"u_min" : 0.0
},
{
"d" : "2023-04-24",
"u_max" : 31600.0,
"u_min" : 0.0
},
{
"d" : "2023-04-25",
"u_max" : 30750.0,
"u_min" : 22860.0
},
{
"d" : "2023-04-26",
"u_max" : 22860.0,
"u_min" : 17350.0
},
{
"d" : "2023-04-27",
"u_max" : 17320.0,
"u_min" : 12360.0
},
{
"d" : "2023-04-28",
"u_max" : 48010.0,
"u_min" : 840.0
},
{
"d" : "2023-04-29",
"u_max" : 47470.0,
"u_min" : 34640.0
},
{
"d" : "2023-04-30",
"u_max" : 34640.0,
"u_min" : 27350.0
},
{
"d" : "2023-05-01",
"u_max" : 27350.0,
"u_min" : 21840.0
},
{
"d" : "2023-05-02",
"u_max" : 21840.0,
"u_min" : 17350.0
},
{
"d" : "2023-05-03",
"u_max" : 17350.0,
"u_min" : 13880.0
},
{
"d" : "2023-05-04",
"u_max" : 13910.0,
"u_min" : 11340.0
},
{
"d" : "2023-05-05",
"u_max" : 11340.0,
"u_min" : 9660.0
},
{
"d" : "2023-05-06",
"u_max" : 9660.0,
"u_min" : 8610.0
},
{
"d" : "2023-05-07",
"u_max" : 8640.0,
"u_min" : 7760.0
},
{
"d" : "2023-05-08",
"u_max" : 7760.0,
"u_min" : 7360.0
}
],
"status" : "OK",
"title" : "Graph counter month"
}
Now my wish: I want to send myself a daily report of the past day in an email with various data using dzVents, for that I have to extract the last entry of u_max and u_min from the JSON from the buffer tank.
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
}
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:)
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
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.