I changed the script once more and now I get the values of 24 hours before.
Code: Select all
return {
active = true,
on = {
timer = { 'at *:05' }, -- every minute for testing, every hour when active
httpResponses = { 'GasmeterRetrieved' } -- matches callback string below
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'http://192.168.1.1:8080/json.htm?type=command¶m=graph&sensor=counter&idx=16&range=day',
method = 'GET',
callback = 'GasmeterRetrieved'
})
elseif (item.isHTTPResponse) then
if (item.ok and item.isJSON) then
domoticz.utils.dumpTable(item.json) -- dumpTable laat alle waarden zien, mooi voor debugging
domoticz.devices('Gas yesterday').updateGas(item.json.result[25].mu*1000)
else
-- oops
domoticz.log('Error fetching Gasmeter data', domoticz.LOG_ERROR)
domoticz.log(item.data, domoticz.LOG_ERROR)
end
end
end
}
It's nice to know and external circumstances are in my mind, so I don't need to calculate that.
My daily results show in mindergas.nl which calculates by using 'gewogen graaddagen'.
The best result of this excercise is to be happy programming and learn a bit more about Domoticz.