aboutsummaryrefslogtreecommitdiffstats
path: root/snag/data.py
diff options
context:
space:
mode:
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 = {