Page 1 of 1
extract 5 minute Toon data from domoticz.db
Posted: Sunday 19 June 2016 1:20
by geoffrey
Hello,
I would like to extract my 5 minute P1 E readings from Toon and my hourly P1 G readings from Toon out of the domoticz.db so I can back them up in a detail database.
Not sure which tables to use for this... Any hints?
Or is this also extractable through the JSON i/f? my Toon P1 E sensor id =11, my G sensor id =12...
any help appreciated.
G.
Re: extract 5 minute Toon data from domoticz.db
Posted: Sunday 19 June 2016 15:05
by dannybloe
You could try
dzVents and have it collect 5 minutes worth of samples using a 'historical variable'. Combine this with a script that runs every 5 minutes and you could serialize it to some other system. All in a Lua script. Takes you just a few lines of code. That way you don't need low-level db access.
Something like this:
Code: Select all
return {
active = true, -- set to true to activate this script
on = {
'myToonDevice',
['timer'] = 'every 5 minutes',
},
data = {
energyReadings = { history = true, maxMinutes = 5 }
},
execute = function(domoticz, toon, triggerInfo)
if (triggerInfo.type == domoticz.EVENT_TYPE_DEVICE) then
-- toon was updated, add the reading to the data set
domoticz.data.energyReadings.add(toon.utility) -- holds the current reading
else
-- timer event was triggered
-- so 5 minutes has passed
-- at this point you can do something with the historical data
domoticz.data.energyReadings.forEach(function(watt)
-- collect
end)
-- save it somewhere
-- reset the readings for the next 5 minutes
domoticz.data.energyReadings.reset();
end
end
}