StefaE / PVForecast

Forecasts to optimize electricity consumption for rooftop PV (photo-voltaic) installations
GNU General Public License v3.0
50 stars 13 forks source link

support influxdb_v2 #2

Closed astrakid closed 3 years ago

astrakid commented 3 years ago

hi, just found your project, thanks for that. because i am not using solaranzeige, but my own dashboards (grafana), i would like to get support for influxdb_v2. i would like to support, but have not that much programming knowledge. regards, andre

StefaE commented 3 years ago

Hi Andre, all influx related code is in influx.py. It appears to me you'd need change from influxdb to influxdb-client

There are three methods in influx.py:

Let me know if you have something, then we can share it through the repo :-)

astrakid commented 3 years ago

yes, i think you are right an dinfluxdb-client is necessary. the major change is switching from user and password authentication to org, token and buckets:

my_token = my-token my_org = "my-org" bucket = "system"

establish connection: client = InfluxDBClient(url="http://localhost:9999", token=token, org=org)

write_api = client.write_api()

write_api.write("my-bucket", "my-org", ["h2o_feet,location=coyote_creek water_level=1"]) or write_api.write("my-bucket", "my-org", ["h2o_feet,location=coyote_creek water_level=1".encode()]) or write_api.write("my-bucket", "my-org", Point("h2o_feet").tag("location", "coyote_creek").field("water_level", 1).time(1)) or write_api.write("my-bucket", "my-org", [{"measurement": "h2o_feet", "tags": {"location": "coyote_creek"}, "fields": {"water_level": 1}, "time": 1}])

i will try to look into influx.py.

astrakid commented 3 years ago

the new influxdbclient supports influxdb 1.8+. i think it makes sense to create a new module influx2.py. so we won't break current functionality and you can switch between influxdb <1.8 and 1.8+. what do you think?

StefaE commented 3 years ago

makes sense - let's do an influx2.py and then, once we see what it takes, we figure out how to make this easy for the user ...

StefaE commented 3 years ago

Alpha version of merged influx.py shared with astrakid for testing.

StefaE commented 3 years ago

Merged into trunk, released as v1.01 Thx. @astrakid for patiently testing :-)

astrakid commented 3 years ago

thanks for implementing it! testing was the least i could do!