X-Git-Url: https://git.toastfreeware.priv.at/chrisu/seepark.git/blobdiff_plain/dbae96a3ccf844c03b456556dc723946030b24ae..80996a20e1f1986d827c9af79aa4932fbfc29b2e:/web/seepark_web.py?ds=sidebyside diff --git a/web/seepark_web.py b/web/seepark_web.py index 03d5760..a6d3930 100644 --- a/web/seepark_web.py +++ b/web/seepark_web.py @@ -180,13 +180,9 @@ def openweathermapdata(cityid): return result -def currentairtemperature(apikey, cityid): - """Retruns the tuple temperature, datetime (as float, datetime) in case of success, otherwise None, None.""" - try: - url, weatherdata = openweathermap_json(apikey, cityid) - return weatherdata['main']['temp'], datetime.datetime.fromtimestamp(weatherdata['dt']) - except OpenWeatherMapError: - return None, None +def currentairtemperature(cityid): + result = OpenWeatherMap.query.filter_by(cityid=cityid).order_by(OpenWeatherMap.datetime.desc()).first() + return result.temp, result.datetime def currentwatertemperature(sensorid): @@ -275,7 +271,7 @@ def data(timespan): @app.route("/") def index(): - airvalue, airtime = currentairtemperature(apikey, cityid) + airvalue, airtime = currentairtemperature(cityid) watervalue, watertime = currentwatertemperature(mainsensor) return render_template(