changeset 1271:398bd2b2490c

new graph view. some autolock and BT code Ignore-this: 35b33edca6f3a07444a11c23b903a63a darcs-hash:f7235b0a0a8565874db0143df4feb06cdf8c7efb
author drewp <drewp@bigasterisk.com>
date Sat, 20 Apr 2019 23:44:18 -0700
parents 114d20be3314
children 298948c177ed
files service/frontDoorLock/front_door_lock.py service/frontDoorLock/index.html service/frontDoorLock/requirements.txt
diffstat 3 files changed, 49 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- 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__':
--- 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 @@
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <script src="/lib/polymer/1.0.9/webcomponentsjs/webcomponents.min.js"></script>
     <script src="/lib/require/require-2.3.3.js"></script>
-    <script>
-     requirejs.config({
-       paths: {
-         "streamed-graph": "/rdf/streamed-graph",
-         "quadstore": "/rdf/quadstore",
-         "async-module": "/lib/async/80f1793/async",
-         "async": "/lib/async/80f1793/async",
-         "jsonld-module": "/lib/jsonld.js/0.4.11/js/jsonld",
-         "jsonld": "/lib/jsonld.js/0.4.11/js/jsonld",
-         "rdfstore": "/lib/rdf_store/0.9.7/dist/rdfstore",
-         "moment": "/lib/moment.min",
-         "underscore": "/lib/underscore-1.5.2.min",
-       }
-     });
-    </script>
-    <script>
-     window.NS = {
-       dev: 'http://projects.bigasterisk.com/device/',
-       room: 'http://projects.bigasterisk.com/room/',
-       rdfs: 'http://www.w3.org/2000/01/rdf-schema#',
-       sensor: 'http://bigasterisk.com/homeauto/sensor/',
-     };
-    </script>
+    <script src="/rdf/common_paths_and_ns.js"></script>
     <link rel="import" href="/rdf/streamed-graph.html">
     <link rel="import" href="/lib/polymer/1.0.9/polymer/polymer.html">
     <link rel="import" href="/rdf/rdf-oneshot.html">
@@ -179,5 +157,29 @@
       </script>
     </dom-module>
     <door-control></door-control>
+
+    <template id="t" is="dom-bind">
+      <streamed-graph url="graph/events" graph="{{graph}}"></streamed-graph>
+      <div id="out"></div>
+      <script type="module" src="/rdf/streamed_graph_view.js"></script>
+    </template>
+
+    <style>
+     .served-resources {
+         margin-top: 4em;
+         border-top: 1px solid gray;
+         padding-top: 1em;
+     }
+     .served-resources a {
+         padding-right: 2em;
+     }
+    </style>
+
+    <div class="served-resources">
+      <a href="stats/">/stats/</a>
+      <a href="graph">/graph</a>
+      <a href="graph/events">/graph/events</a>
+      <a href="output">(post) output</a>
+    </div>
   </body>
 </html>
--- 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