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.