aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/neohub.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/neohub.py')
-rw-r--r--scripts/neohub.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/scripts/neohub.py b/scripts/neohub.py
index 2a61a21..9ee471e 100644
--- a/scripts/neohub.py
+++ b/scripts/neohub.py
@@ -21,7 +21,29 @@ async def run():
hub_data, devices = await hub.get_live_data()
for device in devices['thermostats']:
print(f"Temperature in zone {device.name}: {device}")
- values = (datetime.utcnow(), device.time, device.device_id, device.away, device.heat_mode, device.heat_on, device.current_floor_temperature, device.target_temperature, device.temperature)
- common.dbi(common.sql[common.name], values)
+ values = (
+ datetime.utcnow(),
+ device.time,
+ device.device_id,
+ device.away,
+ device.heat_mode,
+ device.heat_on,
+ device.current_floor_temperature,
+ device.target_temperature,
+ device.temperature)
+
+ sql = """ INSERT INTO neohub
+ (timestamp,
+ time,
+ device_id,
+ away,
+ heat_mode,
+ heat_on,
+ current_floor_temperature,
+ target_temperature,
+ temperature)
+ VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s)"""
+
+ common.dbi(sql, values)
asyncio.run(run())