# HG changeset patch # User drewp@bigasterisk.com # Date 1458559125 25200 # Node ID ba11498148778a8a5c256796cc87515aeec0c220 # Parent 1e93ee96f183a2f820c200301bc403b5114f77bb pi device support for motionStart edge trigger Ignore-this: 1eda3d0bed8def055573fdc1db3cd7c3 diff -r 1e93ee96f183 -r ba1149814877 service/piNode/devices.py --- 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'): diff -r 1e93ee96f183 -r ba1149814877 service/reasoning/actions.py --- 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) diff -r 1e93ee96f183 -r ba1149814877 service/reasoning/input/startup.n3 --- 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 @@ is :source of :reasoning; rdfs:label "slash arduino" . is :source of :reasoning; rdfs:label "bed pi" . is :source of :reasoning; rdfs:label "brace arduino" . + is :source of :reasoning; rdfs:label "changing pi" . + +# is :source of :reasoning; rdfs:label "changing camera" . is :source of :reasoning; rdfs:label "wifi usage" . is :source of :reasoning; rdfs:label "env" . diff -r 1e93ee96f183 -r ba1149814877 service/reasoning/rules.n3 --- 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: . +{ sensor:buttonAriBed :buttonState :press } => { + :starTrekLight :brightness 0.0 . +} . + +{ :sees :noMotion } => { + :changingWhite :brightness 0.0 . + } . + +{ :sees :motion } => { + :changingWhite :brightness 0.2 . +} . + +{ :sees :motionStart } => { + :changingCam :grab . + } . \ No newline at end of file