def render_tempSection(self, ctx, data): try: temps = dict.fromkeys(["ariBedroom", "downstairs", "livingRoom", "bedroom", "KSQL"]) temps.update(getAllTemps()) return T.raw(render.tempsection(temps=temps)) except Exception, e: return T.div["Error creating temperature graph: %s" % e]
def render_tempSection(self, ctx, data): try: temps = dict.fromkeys( ['ariBedroom', 'downstairs', 'livingRoom', 'bedroom', 'KSQL']) temps.update(getAllTemps()) return T.raw(render.tempsection(temps=temps)) except Exception, e: return T.div["Error creating temperature graph: %s" % e]
def child_tempSection(self, ctx): temps = dict.fromkeys( ['ariBedroom', 'downstairs', 'livingRoom', 'bedroom', 'KSQL']) temps.update(getAllTemps()) return jsonlib.dumps([ dict(name=k, val="%.1f °F" % v if v is not None else '?') for k, v in sorted(temps.items(), key=lambda (k, tp): tp, reverse=True) ])
def child_tempSection(self, ctx): temps = dict.fromkeys(["ariBedroom", "downstairs", "livingRoom", "bedroom", "KSQL"]) temps.update(getAllTemps()) return jsonlib.dumps( [ dict(name=k, val="%.1f °F" % v if v is not None else "?") for k, v in sorted(temps.items(), key=lambda (k, tp): tp, reverse=True) ] )
""" write the automatic last line to LCD /lastLine """ import sys, time sys.path.append("/my/site/magma") from datetime import datetime from graphitetemp import getAllTemps import restkit # needs poller with status report while True: fd = restkit.Resource("http://bang:9081/") allTemp = getAllTemps() now = datetime.now() line = "%02d:%02d %02dF in, %02dF out" % ( now.hour, now.minute, allTemp.get("livingRoom", 0), allTemp.get("frontDoor", 0), ) fd.put("lastLine", payload=line) time.sleep(60)