Page 1 of 1

How to access historical sensor data?

Posted: Thursday 11 June 2020 14:54
by Bikey
Hi,

I'm slowly starting to learn DzVents and using it for extra functions, but run into questions on how to solve things.

So now, this is my situation:

I have built a DzVents script that needs to calculate the average power from my Solar-system every minute, over the last 3 or 5 minutes, to activate or stop the charging my car.

I have got this working by storing the values of the Domoticz Electricity device in a (global) persistent variable with history, and then use the "avgSince" function to get the average. That works fine.

However: I was wondering: the Domoticz Electricity Device is already logging the history of the actual power in the Domoticz database. It therefore seems redundant to store the (short term) history as wel in the DzVents persistent variable.

Is there a way to get the historic values of the Electricity Device from the Domoticz database in DzVents for use in the avgSince calculation? I couldn't find that in the documentation or in this forum.

Re: How to access historical sensor data?

Posted: Thursday 11 June 2020 15:24
by waaren
Bikey wrote: Thursday 11 June 2020 14:54 Is there a way to get the historic values of the Electricity Device from the Domoticz database in DzVents for use in the avgSince calculation? I couldn't find that in the documentation or in this forum.
You can get the historic values of the Electricity device using the API

Code: Select all

http://<domoticz IP: domoticz port>/json.htm?type=graph&sensor=counter&idx=<device idx>&range=day
This will give you the history data with a granularity of 5 minutes.
You cannot use this data in the avgSince function because this function it tailor made for the timeSince format in persistent historical data.

Re: How to access historical sensor data?

Posted: Thursday 11 June 2020 15:38
by Bikey
Ah, thanks, for the tip.
The granularity of 5 minutes is too coarse for my use case, so I will stick to using the DzVents persistent variable then and the easy use of the statistical functions!