diff options
author | dennis <d@ennis.no> | 2023-02-01 19:38:11 +0100 |
---|---|---|
committer | dennis <d@ennis.no> | 2023-02-01 19:38:11 +0100 |
commit | e6374e69361200ad2514f4ee6ea5823903fe1443 (patch) | |
tree | 6d730c3c87e156acee25f6393d53166bbe30679c /neohub2pgsql.py | |
parent | forgot to remove debug-message (diff) | |
download | energyscripts-e6374e69361200ad2514f4ee6ea5823903fe1443.tar.gz |
use new dbi
Diffstat (limited to 'neohub2pgsql.py')
-rwxr-xr-x | neohub2pgsql.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/neohub2pgsql.py b/neohub2pgsql.py index 452f5a9..5c62606 100755 --- a/neohub2pgsql.py +++ b/neohub2pgsql.py @@ -1,20 +1,15 @@ #!/usr/bin/python3 import os -import pickle import asyncio from datetime import datetime -from litequeue import SQLQueue import neohubapi.neohub as neohub - -from todb import todb +from common import dbi neohub_ip = os.environ['el_neohub_ip'] neohub_port = os.environ['el_neohub_port'] -q = SQLQueue("litequeue.db", maxsize=None) - async def run(): # Legacy connection hub = neohub.NeoHub(neohub_ip, int(neohub_port)) @@ -26,7 +21,7 @@ async def run(): 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) - q.put(pickle.dumps([sql, values])) + dbi(sql, values) asyncio.run(run()) |