Mercurial > code > home > repos > homeauto
changeset 1293:2f1f1d848bcf
rm frontdooropen
Ignore-this: 37cd3c1540800381404d823a2575cfec
darcs-hash:bdb5f20cfefd027690f1fae735fe364f8048e455
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sun, 21 Apr 2019 01:29:29 -0700 |
parents | e136ee9feffd |
children | ef41e85dccf3 |
files | service/frontdooropen.py |
diffstat | 1 files changed, 0 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/service/frontdooropen.py Sun Apr 21 01:28:47 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -#!/my/proj/homeauto/service/frontDoorArduino/bin/python -from pymongo import Connection -from dateutil.tz import tzlocal -import restkit, time, datetime -from web.utils import datestr - -c3po = restkit.Resource('http://bang:9040/') -sensor = Connection("bang", 27017, tz_aware=True)['house']['sensor'] - -lastSent = None - -while True: - q = {"name":"frontDoor", "state":"open"} - if lastSent is not None: - q['t'] = {"$gt":lastSent} - - for row in sensor.find(q).sort([('t',-1)]).limit(1): - t = row['t'].astimezone(tzlocal()) - msg = "front door opened at %s" % t.replace(microsecond=0).time().isoformat() - if lastSent is not None: - msg += " (previous was %s)" % datestr(lastSent, datetime.datetime.now(tzlocal())) - for u in ["http://bigasterisk.com/foaf.rdf#drewp", "http://bigasterisk.com/kelsi/foaf.rdf#kelsi"]: - c3po.post(path='', payload=dict(msg=msg, user=u, mode='email')) - - lastSent = row['t'] - - time.sleep(1)