nmakel / solaredge_modbus

SolarEdge Modbus data collection library
MIT License
145 stars 34 forks source link

support for influxdb 2.0 #42

Open frezeen opened 2 years ago

frezeen commented 2 years ago

hi,please can u add support for influxdb api v2?

nmakel commented 2 years ago

Can you share how far you've gotten modifying example_influxdb.py to get it to work?

frezeen commented 2 years ago

no, sorry im not a programmer i dont know how to add it. this is what i got when try to connect to influxdb2 (latest)

today at 01:26:34 Container started
today at 01:26:30 influxdb.exceptions.InfluxDBClientError: 401: {"code":"unauthorized","message":"Unauthorized"}
today at 01:26:34 Traceback (most recent call last):
today at 01:26:34   File "example_influxdb.py", line 171, in <module>
today at 01:26:34     client.write_points(json_body)
today at 01:26:34   File "/usr/local/lib/python3.7/site-packages/influxdb/client.py", line 608, in write_points
today at 01:26:34     consistency=consistency)
today at 01:26:34   File "/usr/local/lib/python3.7/site-packages/influxdb/client.py", line 685, in _write_points
today at 01:26:34     protocol=protocol
today at 01:26:34   File "/usr/local/lib/python3.7/site-packages/influxdb/client.py", line 419, in write
today at 01:26:34     headers=headers
today at 01:26:34   File "/usr/local/lib/python3.7/site-packages/influxdb/client.py", line 378, in request
today at 01:26:34     raise InfluxDBClientError(err_msg, response.status_code)
today at 01:26:34 influxdb.exceptions.InfluxDBClientError: 401: {"code":"unauthorized","message":"Unauthorized"}

i read this one but dont know if help, its hard for me to understand: https://john.soban.ski/refactor-python-to-influx-2.html

Jusufs commented 1 year ago

I would prefer to storage not the whole transfer but some parsed important values. I will try to do it. This approach is also valid for openhab persistence.

Stoischo commented 1 year ago

I have modified the example script for influxdb api v2 (see attachment) according to this documentation: https://www.influxdata.com/blog/getting-started-with-python-and-influxdb-v2-0/

Only thing you have do to is to import this library: pip install influxdb-client

Example call: ./example_influxdbV2.py --influx_token <your_token> influx_org <your_org> --influx_bucket <your_bucket> --influx_url http://<your_ip>:8086 <your_inverter_ip> <your_inverter_port>

example_influxdbV2.py.zip