Page 1 of 1

tendances value in the dzvent script

Posted: Tuesday 28 January 2025 20:54
by pierrotori
hi,

i have a rfx meter counter. Is it possible to get the value 349 tendance water in the dzvents script ?
rfx_meter.png
rfx_meter.png (28.53 KiB) Viewed 1454 times
Pierrotori

Re: tendances value in the dzvent script

Posted: Tuesday 28 January 2025 23:33
by waltervl
I believe it is calculated by the highcharts graph module on the webgui part. So not available in dzvents.
You could ofcourse have dzvents calculate a trend based on the values in the database.

Re: tendances value in the dzvent script

Posted: Wednesday 29 January 2025 8:00
by pierrotori
if i would like to use the function in dzvents to calculate a trend bases, i suppose i use a sqlite function, is it correct ?

but by default sqlite is not installed

Re: tendances value in the dzvent script

Posted: Wednesday 29 January 2025 8:09
by waltervl
No, sqlite is never needed to do dzvents actions.
You probably need an Domoticz json API param=graph call to get the history data https://wiki.domoticz.com/Domoticz_API/ ... 7s#History
From that data you can calculate the trend with dzvents/lua. There will probably be Lua functions for that.

tendances value in the dzvent script

Posted: Wednesday 29 January 2025 17:16
by pierrotori
very good, thanks a lot i continue to update the dzvents script

Re: tendances value in the dzvent script

Posted: Saturday 01 February 2025 10:47
by pierrotori
i try this

Code: Select all

http://xxx.xxx.xx.x:8080/json.htm?groupby=month&idx=625&param=graph&sensor=counter&type=command
, but no tendance water in the result of http

Re: tendances value in the dzvent script

Posted: Saturday 01 February 2025 11:59
by waltervl
As said before, the web graph module highcharts that Domoticz is using is calculating the tendency itself. As input it is using the same raw data from the API calls you now used.
So you have to calculate the tendency yourself with dzvents the same way as the highcharts module is doing.

Re: tendances value in the dzvent script

Posted: Sunday 09 March 2025 9:28
by pierrotori
i found the formule

n = len(days)
sum_x = sum(days)
sum_y = sum(water)
sum_xx = sum(days * days)
sum_xy = sum(days * water)

# Formules pour la pente (slope) et l'ordonnée à l'origine (intercept)
# slope = (n∑(xy)−∑x∑y)/(n∑(x^2)-∑(x)^2)
slope = (n * sum_xy - sum_x * sum_y) / (n * sum_xx - sum_x ^2)
# intercept = (∑y - slope * ∑x) /n
intercept = (sum_y - slope * sum_x) / n

tendance = slope * days + intercept