aboutsummaryrefslogtreecommitdiffstats
path: root/snag/data.py
diff options
context:
space:
mode:
authorMatt Kohls <mattkohls13@gmail.com>2023-10-17 17:10:13 -0400
committerMatt Kohls <mattkohls13@gmail.com>2023-10-17 17:10:13 -0400
commit8b7c8bf1e8ecbd6b9fa79a057752535d024e940c (patch)
tree2a48dcc2fe164c18b639d744c17e3d149c989fdf /snag/data.py
parentc8ef8843aaaf28bc38b544ae8ac72accf233aead (diff)
downloadsensor-aggregator-8b7c8bf1e8ecbd6b9fa79a057752535d024e940c.tar.gz
sensor-aggregator-8b7c8bf1e8ecbd6b9fa79a057752535d024e940c.tar.bz2
sensor-aggregator-8b7c8bf1e8ecbd6b9fa79a057752535d024e940c.zip
Hotfixes
Minor tweaks based on things I noticed with real data
Diffstat (limited to 'snag/data.py')
-rw-r--r--snag/data.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/snag/data.py b/snag/data.py
index 3bf8df3..69f9849 100644
--- a/snag/data.py
+++ b/snag/data.py
@@ -6,11 +6,19 @@ from flask import (
Blueprint, flash, g, redirect, render_template, request, url_for, json
)
from werkzeug.exceptions import abort
-from datetime import datetime
+from datetime import datetime, timedelta
from snag.db import get_db
+import time
bp = Blueprint('data', __name__, url_prefix='/data')
+# Temp dst function, should add this to database to track instead
+def is_dst_aware(deviceId):
+ if (deviceId in [2]):
+ return False
+ else:
+ return True
+
# Process json data
#
# Expects something like this:
@@ -43,6 +51,10 @@ def unpack_json_scheme_1(req):
if 'status' in req:
if 'timeStamp' in req['status'][0]:
now = req['status'][0]['timeStamp']
+ now = datetime.strptime(now, "%Y-%m-%dT%H:%M:%SZ")
+ if not is_dst_aware(deviceId) and time.daylight:
+ now = now + timedelta(hours=1)
+ now = now.strftime("%Y-%m-%d %H:%M:%S")
else:
now = datetime.now()
battery = req['status'][0]['battery']
@@ -55,6 +67,10 @@ def unpack_json_scheme_1(req):
humidity = environment['humidity']
pressure = environment['pressure']
now = environment['timeStamp']
+ now = datetime.strptime(now, "%Y-%m-%dT%H:%M:%SZ")
+ if not is_dst_aware(deviceId) and time.daylight:
+ now = now + timedelta(hours=1)
+ now = now.strftime("%Y-%m-%d %H:%M:%S")
if env == 'outdoor':
lux = environment['lux']
uv = environment['uv']
@@ -102,7 +118,7 @@ def get_devices():
for env in envs:
envDict = {
"environment" : env["environment"],
- # "environmentDesc" : env["environmentDescription"]
+ "environmentDesc" : env["environmentDescription"]
}
envList.append(envDict)
deviceLine = {