Good point, I changed the IP and the username/password for the post only. I was finally able to do it but by changing how I pass the variable. I made it work using this. There is a tag named [groep] which contains a.o. Dryer and Oven. The measurement is named kDh.
from influxdb import InfluxDBClient
def read_energy_data(test):
client = InfluxDBClient(host=â192.168.178.106â, port=8086, username=âadminâ, password=âHello1234â)
client.switch_database(âFamilieBotâ)
results = client.query((âSELECT last(Watt),groep from kWh Group by groep ORDER by time DESC LIMIT 1â) )
points = results.get_points(tags={âgroepâ:test})
for item in points:
return item[âlastâ]
print(item[âlastâ])
Thank you for the initialize database comment, I have now added it to the connect string. Apparently the keyword is database (and not dbname or databasename). I could not find that in the documentation on github but found it on the forum.