Move formatting water temperature/time to template.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 4 Jul 2018 19:09:13 +0000 (21:09 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 4 Jul 2018 19:09:13 +0000 (21:09 +0200)
web/seepark_web.py
web/templates/seepark_web.html

index 3ca0b51eb547d7e20a062442633c00409a98d412..82b3323c4c558bb0b3280c883fa34d7ae46f7ea3 100644 (file)
@@ -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/<version>/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',
index 2fccfd6ba030e78be45265bbf5e82cdf4886ef4b..3fed3e96b29c35ba9a977f741fbaef9534ac978e 100644 (file)
@@ -34,8 +34,8 @@
                        {% endif %}
                </p>
                <p id="currentwater">
-                       <strong>Wasser: {{ watervalue }}°C</strong><br />
-                       <small>({{ watertime }})</small>
+                       <strong>Wasser: {{ watervalue|round(1) }}°C</strong><br />
+                       <small>({{ watertime.strftime('%Y-%m-%d %H:%M') }})</small>
                </p>
                </div>