diff service/frontDoorLock/front_door_lock.py @ 575:1209229cd56e

faster keepalive from esp chip. report aliveness into the graph. more programming tasks in tasks.py Ignore-this: f8fca86291d3082cb309524fbd5baf1c
author drewp@bigasterisk.com
date Mon, 06 May 2019 21:06:08 -0700
parents 2d8a5532f1b5
children 150aa09c9723
line wrap: on
line diff
--- a/service/frontDoorLock/front_door_lock.py	Mon May 06 00:19:08 2019 -0700
+++ b/service/frontDoorLock/front_door_lock.py	Mon May 06 21:06:08 2019 -0700
@@ -171,6 +171,14 @@
                                 stateFromMqtt(payload))
 
     mqtt.subscribe(espName + b"/switch/strike/state").subscribe(on_next=toGraph)
+
+    def setEspState(payload):
+        log.info('esp state change %r', payload)
+        masterGraph.patchObject(ctx, ROOM['frontDoorLock'], ROOM['espMqttConnection'],
+                                ROOM['mqtt' + payload.decode('ascii').capitalize()])
+    
+    mqtt.subscribe(espName + b"/status").subscribe(on_next=setEspState)
+    
     port = 10011
     reactor.listenTCP(port, cyclone.web.Application(
         [