dzvents lua script to push data to influxdb

Moderator: leecollings

Post Reply
averter
Posts: 45
Joined: Thursday 24 February 2022 8:32
Target OS: Linux
Domoticz version: 2024.4
Contact:

dzvents lua script to push data to influxdb

Post by averter »

I have two raspberries:
  • one with influxdb v1 that stores the power consumption of the home,
  • and another with domoticz + influxdb v2, and that stores all other kinds of data, including (unfortunately) the energy consumed by my EV (via dombusevse https://www.creasol.it/en/products/domo ... iy-wallbox).
NOTE: I need to have this separate setup because the system to measure the power consumption was designed for influxdb v1 and the creator still had no time to update it to v2 (long story). I know this setup is not ideal but I had no other choice...

The problem: Domoticz is sending all data to influxdb v2, but I want the EV energy to be added to the influxdb v1 in the other raspberry...and I don't think this is possible with influxlink (to have data from some sensors to go to one server with v2 and others to another server with v1)?

The possible solution: a dzvents lua script to push the data to influxdb v1 when the EV energy sensor "dombus - (1.7) EV Energy" changes from 0 (starts charging)? I'm a noob at dzvents lua, so any help is greatly appreciated. Currently I'm doing the process manually, i.e., I read the values of consumed energy from domoticz and use a curl to send it to the rpi.

Code: Select all

curl -i -XPOST 'http://192.168.88.10:8086/write?db=PMONITOR&rp=rp_5min' --data-binary 'home_energy_5m energy=13.76 1711920245000000000'
Thanks in advance.
User avatar
waltervl
Posts: 5376
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: dzvents lua script to push data to influxdb

Post by waltervl »

Perhaps easier would be to use the HTTPLink function to send data to the V1 Influx. HTTPLink is the predecessor of the Influxdb link.
The instruction is still here, but could be outdated: https://www.domoticz.com/wiki/HttpLink#Example
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
averter
Posts: 45
Joined: Thursday 24 February 2022 8:32
Target OS: Linux
Domoticz version: 2024.4
Contact:

Re: dzvents lua script to push data to influxdb

Post by averter »

This is brilliant! Thanks so much @waltervi. I think that I've configured everything correctly but I just want to make sure that the nomenclatures of influxdb of the powermonitoring system that I am using (measurement, retention policy, field, etc.) and the one in the instruction site (series, name, column, variable, etc.) that you've sent me are matching well.

Essentially, the IDB structure is
  • dbname: PMONITOR
  • retention policy: rp_5min
  • measurement name: home_energy_5m
  • field: energy

Can you please have a look at the setup below to double check?

Code: Select all

URL: http://192.168.88.10:8086/db/PMONITOR&rp=rp_5min/home_energy_5m?u=myusername&p=mysecretpassword
Method: POST
Authentication: None
DATA: [{"name":"energy","columns":["time","val"],"points":[[%t3,%v]]}]
Screenshot from 2024-04-02 10-26-20.png
Screenshot from 2024-04-02 10-26-20.png (73.01 KiB) Viewed 986 times
User avatar
waltervl
Posts: 5376
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: dzvents lua script to push data to influxdb

Post by waltervl »

Now you have overestimated my capacities.... ;)
I have no idea what influxdb integration is sending compared to the HTTPLink configuration.
Perhaps try it out in a separate V1 influxdb database to test first.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests