aboutsummaryrefslogtreecommitdiffstats
path: root/neohub2pgsql.py
diff options
context:
space:
mode:
authorDennis Eriksen <d@ennis.no>2023-02-01 20:32:11 +0100
committerDennis Eriksen <d@ennis.no>2023-02-01 20:32:11 +0100
commit8d186d39483beff64a1c11f80c6ca5e56dd7bbc5 (patch)
tree2c5a64ace4bd8eabd4d65014c5313bd7edd76191 /neohub2pgsql.py
parentrun queue in batches (diff)
downloadenergyscripts-8d186d39483beff64a1c11f80c6ca5e56dd7bbc5.tar.gz
moving and renaming/breaking everything
Diffstat (limited to 'neohub2pgsql.py')
-rwxr-xr-xneohub2pgsql.py27
1 files changed, 0 insertions, 27 deletions
diff --git a/neohub2pgsql.py b/neohub2pgsql.py
deleted file mode 100755
index 5c62606..0000000
--- a/neohub2pgsql.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/python3
-
-import os
-import asyncio
-from datetime import datetime
-import neohubapi.neohub as neohub
-
-from common import dbi
-
-neohub_ip = os.environ['el_neohub_ip']
-neohub_port = os.environ['el_neohub_port']
-
-async def run():
- # 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}")
- 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)"
- 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)
- dbi(sql, values)
-
-asyncio.run(run())
-