changeset 254:ba1149814877

pi device support for motionStart edge trigger Ignore-this: 1eda3d0bed8def055573fdc1db3cd7c3
author drewp@bigasterisk.com
date Mon, 21 Mar 2016 04:18:45 -0700
parents 1e93ee96f183
children 3657e3f0d5d0
files service/piNode/devices.py service/reasoning/actions.py service/reasoning/input/startup.n3 service/reasoning/rules.n3
diffstat 4 files changed, 32 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/service/piNode/devices.py	Mon Mar 21 04:17:57 2016 -0700
+++ b/service/piNode/devices.py	Mon Mar 21 04:18:45 2016 -0700
@@ -119,14 +119,22 @@
         self.pi.set_mode(17, pigpio.INPUT)
         self.pi.set_pull_up_down(17, pigpio.PUD_DOWN)
 
+    def hostStateInit(self):
+        self.lastRead = None
+
     def poll(self):
         motion = self.pi.read(17)
         
+        oneshot = []
+        if self.lastRead is not None and motion != self.lastRead:
+            oneshot = [(self.uri, ROOM['sees'], ROOM['motionStart'])]
+        self.lastRead = motion
+        
         return {'latest': [
             (self.uri, ROOM['sees'],
              ROOM['motion'] if motion else ROOM['noMotion']),
             self.recentMotionStatement(motion),
-        ], 'oneshot': []}
+        ], 'oneshot': oneshot}
 
     def recentMotionStatement(self, motion):
         if not hasattr(self, 'lastMotionTime'):
--- a/service/reasoning/actions.py	Mon Mar 21 04:17:57 2016 -0700
+++ b/service/reasoning/actions.py	Mon Mar 21 04:18:45 2016 -0700
@@ -38,6 +38,8 @@
                 (URIRef('http://projects.bigasterisk.com/room/storageCeilingLedLong'), ROOM.brightness),
                 (URIRef('http://projects.bigasterisk.com/room/storageCeilingLedCross'), ROOM.brightness),
                 (URIRef('http://projects.bigasterisk.com/room/headboardWhite'), ROOM.brightness),
+                (URIRef('http://projects.bigasterisk.com/room/changingWhite'), ROOM.brightness),
+                (URIRef('http://projects.bigasterisk.com/room/starTrekLight'), ROOM.brightness),
                 (URIRef('http://projects.bigasterisk.com/room/bedLedStrip'), ROOM.color),
             ]:
             url = deviceGraph.value(dev, ROOM.putUrl)
--- a/service/reasoning/input/startup.n3	Mon Mar 21 04:17:57 2016 -0700
+++ b/service/reasoning/input/startup.n3	Mon Mar 21 04:18:45 2016 -0700
@@ -8,6 +8,9 @@
 <http://slash:9059/graph>    is :source of :reasoning; rdfs:label "slash arduino" .
 <http://sticker:9059/graph>  is :source of :reasoning; rdfs:label "bed pi" .
 <http://brace6:9059/graph>   is :source of :reasoning; rdfs:label "brace arduino" .
+<http://changing:9059/graph> is :source of :reasoning; rdfs:label "changing pi" .
+
+#<http://changing:8208/graph> is :source of :reasoning; rdfs:label "changing camera" .
 
 <http://bang:9070/graph>     is :source of :reasoning; rdfs:label "wifi usage" .
 <http://bang:9075/graph>     is :source of :reasoning; rdfs:label "env" .
--- a/service/reasoning/rules.n3	Mon Mar 21 04:17:57 2016 -0700
+++ b/service/reasoning/rules.n3	Mon Mar 21 04:18:45 2016 -0700
@@ -142,4 +142,21 @@
 
 { bed:redButton :buttonState :press } => {
   :headboardWhite :brightness 0.04 .
-} .
\ No newline at end of file
+} .
+
+@prefix sensor:   <http://bigasterisk.com/homeauto/sensor/> .
+{ sensor:buttonAriBed :buttonState :press } => {
+  :starTrekLight :brightness 0.0 .
+} .
+
+{ <http://bigasterisk.com/homeauto/sensor/motion2> :sees :noMotion } => {
+  :changingWhite :brightness 0.0 .
+  } .
+
+{ <http://bigasterisk.com/homeauto/sensor/motion2> :sees :motion } => {
+  :changingWhite :brightness 0.2 .
+} .
+
+{ <http://bigasterisk.com/homeauto/sensor/motion2> :sees :motionStart } => {
+  :changingCam :grab <http://bang:9057/changing.jpg> .
+  } .
\ No newline at end of file