diff options
Diffstat (limited to 'scripts/neohub.py')
-rw-r--r-- | scripts/neohub.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/scripts/neohub.py b/scripts/neohub.py index e15a00e..bf43859 100644 --- a/scripts/neohub.py +++ b/scripts/neohub.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -''' Get stuff from neohub! This is mostly the usage-example from https://gitlab.com/neohubapi/neohubapi/ ''' +""" Get stuff from neohub! This is mostly the usage-example from https://gitlab.com/neohubapi/neohubapi/ """ import asyncio import os @@ -9,20 +9,21 @@ from datetime import datetime import common import neohubapi.neohub as neohub -neohub_ip = os.environ['el_neohub_ip'] -neohub_port = os.environ['el_neohub_port'] -SLEEP = 120 # Sleep between runs +neohub_ip = os.environ["el_neohub_ip"] +neohub_port = os.environ["el_neohub_port"] +SLEEP = 120 # Sleep between runs + async def call_neohub(): - ''' async runner! w00p ''' + """async runner! w00p""" # Legacy connection hub = neohub.NeoHub(neohub_ip, int(neohub_port)) # Or, for a websocket connection: # hub = neohub.Neohub(port=4243, token='xxx-xxxxxxx') # system = await hub.get_system() hub_data, devices = await hub.get_live_data() - for device in devices['thermostats']: - #print(f"Temperature in zone {device.name}: {device}") + for device in devices["thermostats"]: + # print(f"Temperature in zone {device.name}: {device}") values = ( datetime.utcnow(), device.time, @@ -32,9 +33,10 @@ async def call_neohub(): device.heat_on, device.current_floor_temperature, device.target_temperature, - device.temperature) + device.temperature, + ) - sql = """INSERT INTO neohub + sql = """INSERT INTO neohub (timestamp, time, device_id, @@ -47,7 +49,7 @@ async def call_neohub(): VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s)""" common.dbi(sql, values, verbose=True) - common.statein('neohub', device.temperature, 'temperature', '°C', verbose=True) + common.statein("neohub", device.temperature, "temperature", "°C", verbose=True) # Loop it forever |