view service/frontDoorMessage/automsg.py @ 35:912a3dae5c2c

don't break automsg when livingroom temp is missing Ignore-this: 44e1b7c6c671833338af6ad99d93554d
author drewp@bigasterisk.com
date Mon, 06 Aug 2012 20:18:29 -0700
parents 6fd208b97616
children
line wrap: on
line source

"""
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)