Mercurial > code > home > repos > homeauto
changeset 1067:dfb284fb025c
invert support for Pushbutton
Ignore-this: d4b994070114e26700857fcd2cd0118e
darcs-hash:2cc350da1fc7da83153b9b4da89b97a85a9dc9ab
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sat, 02 Apr 2016 23:33:43 -0700 |
parents | a6639d55ad4b |
children | 5b7fdbc73ed5 |
files | service/piNode/config/main.n3 service/piNode/devices.py |
diffstat | 2 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/service/piNode/config/main.n3 Mon Mar 21 04:26:14 2016 -0700 +++ b/service/piNode/config/main.n3 Sat Apr 02 23:33:43 2016 -0700 @@ -79,12 +79,28 @@ @prefix board4pin: <http://bigasterisk.com/homeauto/board4/pin/> . +# pinout: https://www.raspberrypi.org/documentation/usage/gpio-plus-and-raspi2/ ha:node4 a :PiBoard; :hostname "living"; - :onboardDevice ha:livingPiTemp . + :onboardDevice ha:livingPiTemp; + :hasPin + board4pin:GPIO17, + board4pin:GPIO4, + board4pin:GPIO27, + board4pin:GPIO22 . + +board4pin:GPIO17 :gpioNumber 17; :connectedTo sensor:tempHumidLivingRoomCeiling . +board4pin:GPIO4 :gpioNumber 4; :connectedTo :livingRoomLamp1 . +board4pin:GPIO27 :gpioNumber 27; :connectedTo :livingRoomLamp2 . +board4pin:GPIO22 :gpioNumber 22; :connectedTo :bookSwitch . ha:livingPiTemp a :OnboardTemperature . - +sensor:tempHumidLivingRoomCeiling a :TempHumidSensor; + :sees houseLoc:livingRoomCeiling; + :graphiteName "system.house.temp.livingRoomCeiling" . +:livingRoomLamp1 a :LedOutput . +:livingRoomLamp2 a :LedOutput . +:bookSwitch a :Pushbutton; :style :inverted . @prefix board5: <http://bigasterisk.com/homeauto/board5/> . @prefix board5pin: <http://bigasterisk.com/homeauto/board5/pin/> .
--- a/service/piNode/devices.py Mon Mar 21 04:26:14 2016 -0700 +++ b/service/piNode/devices.py Sat Apr 02 23:33:43 2016 -0700 @@ -270,11 +270,16 @@ self.pi.set_mode(self.pinNumber, pigpio.INPUT) self.pi.set_pull_up_down(self.pinNumber, pigpio.PUD_UP) self.lastClosed = None + self.invert = (self.uri, ROOM['style'], + ROOM['inverted']) in self.graph def poll(self): closed = not self.pi.read(self.pinNumber) + if self.invert: + closed = not closed if self.lastClosed is not None and closed != self.lastClosed: + log.debug('%s changed to %s', self.uri, closed) oneshot = [ (self.uri, ROOM['buttonState'], ROOM['press'] if closed else ROOM['release']),