+def currentairtemperature(apikey, cityid):
+ """Retruns the tuple temperature, datetime (as float, datetime) in case of success, otherwise None, None."""
+ try:
+ weatherdata = openweathermap_json(apikey, cityid)
+ return weatherdata['main']['temp'], datetime.datetime.fromtimestamp(weatherdata['dt'])
+ except OpenWeatherMapError:
+ return None, None
+
+
+def currentwatertemperature(sensorid):
+ engine = open_engine(config)
+ 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')
+
+