From: Philipp Spitzer
Date: Wed, 4 Jul 2018 19:09:13 +0000 (+0200)
Subject: Move formatting water temperature/time to template.
X-Git-Url: https://git.toastfreeware.priv.at/chrisu/seepark.git/commitdiff_plain/86bcc8d9b0a98df464ac5cc9fb52c1eb64946eca
Move formatting water temperature/time to template.
---
diff --git a/web/seepark_web.py b/web/seepark_web.py
index 3ca0b51..82b3323 100644
--- a/web/seepark_web.py
+++ b/web/seepark_web.py
@@ -114,7 +114,7 @@ def currentwatertemperature(sensorid):
with engine.connect() as conn:
cursor = conn.execute('select value, timestamp from sensors where sensor_id=%s order by timestamp desc limit 1', sensorid)
result = [dict(row) for row in cursor]
- return result[0]['value'], result[0]['timestamp'].strftime('%Y-%m-%d %H:%M')
+ return result[0]['value'], result[0]['timestamp']
@app.route('/api//sensors/')
@@ -189,7 +189,6 @@ def data(timespan):
def index():
airvalue, airtime = currentairtemperature(apikey, cityid)
watervalue, watertime = currentwatertemperature('0316a21383ff') # config? mainwatertemp?
- watervalue = "{:.1f}".format(watervalue) if isinstance(watervalue, float) else watervalue
return render_template(
'seepark_web.html',
diff --git a/web/templates/seepark_web.html b/web/templates/seepark_web.html
index 2fccfd6..3fed3e9 100644
--- a/web/templates/seepark_web.html
+++ b/web/templates/seepark_web.html
@@ -34,8 +34,8 @@
{% endif %}
- Wasser: {{ watervalue }}°C
- ({{ watertime }})
+ Wasser: {{ watervalue|round(1) }}°C
+ ({{ watertime.strftime('%Y-%m-%d %H:%M') }})