diff service/frontDoorLock/front_door_lock.py @ 1683:437d7263b515

checkpoint service/frontDoorLock
author drewp@bigasterisk.com
date Mon, 27 Sep 2021 23:13:49 -0700
parents 3f6055cfccb2
children 6ee9a1c5a991
line wrap: on
line diff
--- a/service/frontDoorLock/front_door_lock.py	Mon Sep 27 23:05:30 2021 -0700
+++ b/service/frontDoorLock/front_door_lock.py	Mon Sep 27 23:13:49 2021 -0700
@@ -1,4 +1,11 @@
 """
+currently:
+- serves simple.html
+- listens for simple POST requests
+- syncs mqtt frontdoorlock/switch/strike/state into an rdf graph
+- listens for PUT /output with a request for :frontDoorLock :state :unlocked
+
+------
 this service is generalized by mqtt_graph_bridge and rdf_from_mqtt, so delete when those are stable
 
 :frontDoorLock :state :locked/:unlocked
@@ -52,8 +59,8 @@
     def put(self):
         try:
             user = requestUser(self.request)
-        except KeyError:
-            log.warn('request without x-foaf-agent: %s', h)
+        except KeyError as e:
+            log.warn('request without x-foaf-agent: %r', e)
             self.set_status(403, 'need x-foaf-agent')
             return
         arg = self.request.arguments
@@ -87,7 +94,7 @@
         try:
             user = requestUser(self.request)
         except KeyError:
-            log.warn('request without x-foaf-agent: %s', h)
+            log.warn('request without x-foaf-agent: %s', self.request.headers)
             self.set_status(403, 'need x-foaf-agent')
             return
 
@@ -170,7 +177,7 @@
     def post(self):
         body = json.loads(self.request.body)
         log.info('POST bluetoothButton %r', body)
-        if body['addr'] == 'zz:zz:zz:zz:zz:zz' and body['key'] == 'top':
+        if body['addr'] == 'B8:27:EB:95:BE:1C' and body['key'] == 'top':
             log.info('unlock for %r', body['addr'])
             self.settings.mqtt.publish(
                 espName + b"/switch/strike/command", b'ON')