# HG changeset patch # User drewp # Date 1555829058 25200 # Node ID 398bd2b2490c2d00b344801b0d2c470054af8d15 # Parent 114d20be3314c4502a054b858b3e4a9ab6eb9df4 new graph view. some autolock and BT code Ignore-this: 35b33edca6f3a07444a11c23b903a63a darcs-hash:f7235b0a0a8565874db0143df4feb06cdf8c7efb diff -r 114d20be3314 -r 398bd2b2490c service/frontDoorLock/front_door_lock.py --- a/service/frontDoorLock/front_door_lock.py Sat Apr 20 23:41:34 2019 -0700 +++ b/service/frontDoorLock/front_door_lock.py Sat Apr 20 23:44:18 2019 -0700 @@ -117,8 +117,28 @@ self.relock() else: self.timeUnlocked = None - self.masterGraph.patchObject(ctx, self.subj, ROOM['unlockedForSec'], None) - self.masterGraph.patchObject(ctx, self.subj, ROOM['autoLockInSec'], None) + unlockedFor = 0 + if unlockedFor > 3: + # only start showing the count if it looks like we're not + # being repeatedly held open. Time is hopefully more than + # the refresh rate of "reasoning.actions". + self.reportTimes(unlockedFor) + else: + self.clearReport() + + def onUnlockedStmt(self): + self.timeUnlocked = None + + def onLockedStmt(self): + pass + +class BluetoothButton(cyclone.web.RequestHandler): + 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': + log.info('unlock for %r', body['addr']) + self.settings.mqtt.publish("frontdoor/switch/strike/command", 'ON') if __name__ == '__main__': diff -r 114d20be3314 -r 398bd2b2490c service/frontDoorLock/index.html --- a/service/frontDoorLock/index.html Sat Apr 20 23:41:34 2019 -0700 +++ b/service/frontDoorLock/index.html Sat Apr 20 23:44:18 2019 -0700 @@ -7,29 +7,7 @@ - - + @@ -179,5 +157,29 @@ + + + + + +
+ /stats/ + /graph + /graph/events + (post) output +
diff -r 114d20be3314 -r 398bd2b2490c service/frontDoorLock/requirements.txt --- a/service/frontDoorLock/requirements.txt Sat Apr 20 23:41:34 2019 -0700 +++ b/service/frontDoorLock/requirements.txt Sat Apr 20 23:44:18 2019 -0700 @@ -2,5 +2,6 @@ rdflib-jsonld==0.4.0 rdflib==4.2.2 twisted-mqtt==0.3.6 -https://projects.bigasterisk.com/rdfdb/rdfdb-0.7.0.tar.gz +https://projects.bigasterisk.com/rdfdb/rdfdb-0.8.0.tar.gz rx==1.6.1 +git+http://github.com/drewp/scales.git@448d59fb491b7631877528e7695a93553bfaaa93#egg=scales