#!/usr/bin/python3 import sqlite3 from requests import post from time import ctime,sleep print("Starting up ht3logger V1 on "+ctime()) channel_list = { 'ch_V_spare_1' : '80089ae0-fa81-11e9-bdc6-b99d5fa0fe8b', 'T_vorlauf_soll' : 'af1863e0-fa81-11e9-8d30-337b7499db8e', 'T_vorlauf_ist' : 'cbf99f10-fa81-11e9-9709-d55e7ad0883e', 'T_mischer' : '521a0ca0-fa8d-11e9-970f-752aababd342', 'V_heizungs_pumpe' : 'a5958bf0-fa8f-11e9-bf34-4f7c2163b201', 'V_brenner_flamme' : '5ec31d30-fa90-11e9-98b7-3b9f4a33ba29', 'V_leistung' : '81f3ed90-7f7b-11ed-90c6-b747fd43b61f', 'C_brenner_gesamt' : '9bbd1c20-a8ee-11e5-82ab-079b3d8ffc8e' } while True: try: db = sqlite3.connect("/home/pi/HT3/sw/var/databases/HT3_db.sqlite") db.row_factory = sqlite3.Row cursor = db.execute("SELECT * FROM heizgeraet order by utc desc limit 1") except: print("Error accessing Sqlite database.") raise SystemExit(2) for dbvalue in cursor: timestamp = int(dbvalue['UTC'] * 1000) for key,uuid in channel_list.items(): try: #print(key, timestamp, uuid, dbvalue[key]) post('http://localhost/middleware/data.json', data='uuid':uuid,'ts':timestamp,'value':dbvalue[key]}) except: print("Couldn't post to VZ Middleware.") db.close() sleep(10)