Mercurial > code > home > repos > homeauto
diff service/frontDoorLock/front_door_lock.py @ 576:150aa09c9723
new simple mode that can set the door without rdf
Ignore-this: ff9ab7c6507a7b3fb3252f91b078a318
author | drewp@bigasterisk.com |
---|---|
date | Mon, 06 May 2019 21:07:42 -0700 |
parents | 1209229cd56e |
children | 759bf29d9dbe |
line wrap: on
line diff
--- a/service/frontDoorLock/front_door_lock.py Mon May 06 21:06:08 2019 -0700 +++ b/service/frontDoorLock/front_door_lock.py Mon May 06 21:07:42 2019 -0700 @@ -76,6 +76,16 @@ return log.warn("ignoring %s", stmt) +class SimpleState(cyclone.web.RequestHandler): + def post(self): + state = self.request.body.strip().decode('ascii') + if state == 'unlock': + self.settings.autoLock.onUnlockedStmt() + self.settings.mqtt.publish(espName + b"/switch/strike/command", b'ON') + if state == 'lock': + self.settings.autoLock.onLockedStmt() + self.settings.mqtt.publish(espName + b"/switch/strike/command", b'OFF') + class AutoLock(object): def __init__(self, masterGraph, mqtt): @@ -97,7 +107,7 @@ if lockIn < 0: state = g._graph.value(self.subj, ROOM['state']) log.warn(f"timeUnlocked {self.timeUnlocked}, state {state}, " - "unlockedFor {unlockedFor}, lockIn {lockIn}") + f"unlockedFor {unlockedFor}, lockIn {lockIn}") lockIn = 0 g.patchObject(ctx, self.subj, ROOM['unlockedForSec'], Literal(int(unlockedFor))) @@ -184,11 +194,14 @@ [ (r"/()", cyclone.web.StaticFileHandler, {"path": ".", "default_filename": "index.html"}), + (r"/simple/()", cyclone.web.StaticFileHandler, + {"path": ".", "default_filename": "simple.html"}), (r"/graph", CycloneGraphHandler, {'masterGraph': masterGraph}), (r"/graph/events", CycloneGraphEventsHandler, {'masterGraph': masterGraph}), (r'/output', OutputPage), (r'/bluetoothButton', BluetoothButton), + (r'/simpleState', SimpleState), ], mqtt=mqtt, masterGraph=masterGraph,