summaryrefslogtreecommitdiff
path: root/weather-logger-receiver
diff options
context:
space:
mode:
authorpks <pks@pks.rocks>2021-05-11 10:28:37 +0200
committerpks <pks@pks.rocks>2021-05-11 10:28:37 +0200
commit49b5ca867d4e75d53078d872f2759b3d1beac2a4 (patch)
treea85509d3e9a5eac457341c923ec35819e363c541 /weather-logger-receiver
parentef85e805eac28c54c5c342b7d7a713500b286c16 (diff)
fix
Diffstat (limited to 'weather-logger-receiver')
-rwxr-xr-xweather-logger-receiver11
1 files changed, 6 insertions, 5 deletions
diff --git a/weather-logger-receiver b/weather-logger-receiver
index f0db5a4..38a5c81 100755
--- a/weather-logger-receiver
+++ b/weather-logger-receiver
@@ -6,6 +6,7 @@ import signal
import sqlite3
import sys
import time
+import traceback
import yaml
from RFXtrx import PySerialTransport
@@ -38,13 +39,12 @@ def setup_serial(device_path):
def add_data_to_db(data, handle, db_connection):
db_cursor = db_connection.cursor()
columns = ["timestamp", "handle", "temperature"]
- values = [int(time.time()), handle, data.values['Temperature']]
+ values = [str(int(time.time())), f"'{handle}'", str(data.values["Temperature"])]
if "Humidity" in data.values:
columns.append("humidity")
- values.append(data.values['Humidity'])
- db_cursor.execute(f"INSERT INTO weather \
- ({','.join(columns)}) \
- VALUES ({','.join(values)})")
+ values.append(str(data.values["Humidity"]))
+ query = f"INSERT INTO weather ({','.join(columns)}) VALUES ({','.join(values)})"
+ db_cursor.execute(query)
db_connection.commit()
@@ -141,5 +141,6 @@ if __name__ == "__main__":
loop(known_devices, serial_connection, db_connection, logger)
except Exception as e:
logger.error(f"Exception: {e}")
+ traceback.print_exc()
finally:
shutdown(config, serial_connection, db_connection, logger)