tendances value in the dzvent script

Subforum for general discussions. Do not dump your questions/problems here, but try to find the subforum where it belongs!

Moderators: leecollings, remb0

Post Reply
User avatar
pierrotori
Posts: 118
Joined: Tuesday 15 May 2018 0:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: France
Contact:

tendances value in the dzvent script

Post 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 472 times
Pierrotori
rpi : Raspberry Pi 2 Model B Rev 1.1 / Modele : Cortex-A7 armv7l GNU/Linux / Os Name : bullseye
Docker/Domoticz/zwave-ui/homebridge/mosquitto/wireguard
User avatar
waltervl
Posts: 5852
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: tendances value in the dzvent script

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
pierrotori
Posts: 118
Joined: Tuesday 15 May 2018 0:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: France
Contact:

Re: tendances value in the dzvent script

Post 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
rpi : Raspberry Pi 2 Model B Rev 1.1 / Modele : Cortex-A7 armv7l GNU/Linux / Os Name : bullseye
Docker/Domoticz/zwave-ui/homebridge/mosquitto/wireguard
User avatar
waltervl
Posts: 5852
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: tendances value in the dzvent script

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
pierrotori
Posts: 118
Joined: Tuesday 15 May 2018 0:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: France
Contact:

tendances value in the dzvent script

Post by pierrotori »

very good, thanks a lot i continue to update the dzvents script
rpi : Raspberry Pi 2 Model B Rev 1.1 / Modele : Cortex-A7 armv7l GNU/Linux / Os Name : bullseye
Docker/Domoticz/zwave-ui/homebridge/mosquitto/wireguard
User avatar
pierrotori
Posts: 118
Joined: Tuesday 15 May 2018 0:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: France
Contact:

Re: tendances value in the dzvent script

Post 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
rpi : Raspberry Pi 2 Model B Rev 1.1 / Modele : Cortex-A7 armv7l GNU/Linux / Os Name : bullseye
Docker/Domoticz/zwave-ui/homebridge/mosquitto/wireguard
User avatar
waltervl
Posts: 5852
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: tendances value in the dzvent script

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
pierrotori
Posts: 118
Joined: Tuesday 15 May 2018 0:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: France
Contact:

Re: tendances value in the dzvent script

Post 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

rpi : Raspberry Pi 2 Model B Rev 1.1 / Modele : Cortex-A7 armv7l GNU/Linux / Os Name : bullseye
Docker/Domoticz/zwave-ui/homebridge/mosquitto/wireguard
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest