changeset 870:e0f60d0e6e07

faster thermostat button polling. send updates to wallscreen (directly) Ignore-this: 6259a882bbee19ef2dddd7f5b931890 darcs-hash:20130411035144-312f9-2d824c6addc75c06cfc3def8e2d9c9cac95ae615
author drewp <drewp@bigasterisk.com>
date Wed, 10 Apr 2013 20:51:44 -0700
parents 15af9d8c7186
children 78a418407eb9
files service/thermostat/rpi_buttons.py service/thermostat/thermostat.py
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/service/thermostat/rpi_buttons.py	Wed Apr 10 20:51:12 2013 -0700
+++ b/service/thermostat/rpi_buttons.py	Wed Apr 10 20:51:44 2013 -0700
@@ -34,7 +34,7 @@
 prev = None
 prevButton = 0
 buttonHold = 0
-step = .05
+step = .02
 while True:
     a, b = pinInput(PIN_KNOB_A), pinInput(PIN_KNOB_B)
     button = not pinInput(PIN_BUTTON)
--- a/service/thermostat/thermostat.py	Wed Apr 10 20:51:12 2013 -0700
+++ b/service/thermostat/thermostat.py	Wed Apr 10 20:51:44 2013 -0700
@@ -17,7 +17,7 @@
 @inlineCallbacks
 def http(method, url, body=None):
     resp = (yield fetch(url, method=method, postdata=body,
-                        headers={'user-agent': ['thermostat']}))
+                        headers={'user-agent': ['thermostat.py']}))
     if resp.code != 200:
         raise ValueError("%s returned %s: %s" % (url, resp.code, resp.body))
     returnValue(resp.body)
@@ -44,12 +44,16 @@
     def setRequest(self, f):
         db['request'].insert({'tempF': f, 't':datetime.datetime.now(tzlocal())})
         self.step()
+        http('POST', 'http://bang:9102/refreshTemperature')
+        # magma might also like to know
         
     @inlineCallbacks
     def step(self):
         roomF = yield self.getRoomTempF()
         requestedF = self.getRequest()
         active = yield self.active()
+        # bug here where, if something else turned off the heater, we
+        # don't count minsOff right
         minsOff = self.minutesSinceOff()
         minsOn = self.minutesSinceOn()