From 1a5bc1e0c0c441d27dece47f895543a5a7b61ee8 Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Sun, 12 Apr 2015 21:08:16 -0500 Subject: [PATCH] Allow users not using Zimmerman method to use California restriction --- application.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/application.py b/application.py index 1a81387..0b7b33c 100644 --- a/application.py +++ b/application.py @@ -166,7 +166,7 @@ def application(environ, start_response): except: toffset=-1 - if (uwt > 0): + if (key != ''): try: req = urllib2.urlopen('http://api.wunderground.com/api/'+key+'/yesterday/conditions/q/'+urllib.quote(loc)+'.json') dat = json.load(req) @@ -195,26 +195,27 @@ def application(environ, start_response): if v: h_today = safe_float(v, h_today) - # calculate water time scale, per https://github.com/rszimm/sprinklers_pi/blob/master/Weather.cpp - hf = 0 - if (maxh>=0) and (minh>=0): - hf = 30 - (maxh+minh)/2 - #elif (h_today>=0): - # hf = 30 - h_today - tf = 0 - if (meant > -500): - tf = (meant - 70) * 4 - rf = 0 - if (pre>=0): - rf -= pre * 200 - if (pre_today>=0): - rf -= pre_today * 200 - scale = (int)(100 + hf + tf + rf) + if (uwt === 1): + # calculate water time scale, per https://github.com/rszimm/sprinklers_pi/blob/master/Weather.cpp + hf = 0 + if (maxh>=0) and (minh>=0): + hf = 30 - (maxh+minh)/2 + #elif (h_today>=0): + # hf = 30 - h_today + tf = 0 + if (meant > -500): + tf = (meant - 70) * 4 + rf = 0 + if (pre>=0): + rf -= pre * 200 + if (pre_today>=0): + rf -= pre_today * 200 + scale = (int)(100 + hf + tf + rf) - if (scale<0): - scale = 0 - if (scale>200): - scale = 200 + if (scale<0): + scale = 0 + if (scale>200): + scale = 200 # Check weather modifier bits and apply scale modification if ((uwt>>7) & 1):