Fork me on GitHub

pimatic-gpio by Oliver Schneider (sweetpi) | github | npm

pimatic-gpio

Actuators and sensors for the Raspberry Pi GPIO pins. This plugin uses the node.js module onoff.

Plugin Configuration

You can load the plugin by editing your config.json to include:

{ 
   "plugin": "gpio"
}

in the plugins Array.

Device Configuration

Devices can be added by adding them to the devices Array in the config file. Set the class property to GpioSwitch, GpioPresence, or GpioContact, respectively. By default, the device state will be true , i.e. on, opened, or present, when the GPIO pin is HIGH. If you need the device to be active on LOW, set the property inverted to true.

The GpioSwitch device additionally provides the optional defaultState property which can be used to set the initial switch state to the given value. If the property is not present the last state will be recovered from database or it will be set to false if the last state cannot be obtained.

For device configuration options see the device-config-schema file.

GPIO Pin Numbering

Use the GPIO numbers from the RPi Low-level peripherals wiki page.

Internal Pull-up and Pull-down Resistors

On Raspberry Pi, most GPIOs have either their pull-up or pull-down resistor activated by default. For further details, see Configuring pull-up and pull-down resistors.

Device examples

GpioSwitch Device ("active LOW" and "defaultState")

{ 
  "id": "led-light",
  "class": "GpioSwitch", 
  "name": "led light",
  "gpio": 17,
  "inverted": true,
  "defaultState": false
}

GpioPresence Sensor

{ 
  "id": "presence-sensor",
  "class": "GpioPresence", 
  "name": "motion detector",
  "gpio": 18 
}

GpioContact Sensor

{ 
  "id": "contact-sensor",
  "class": "GpioContact", 
  "name": "contact detector",
  "debounceTimeout": 50,
  "gpio": 18 
}

Plugin Config Options

gpio config
OptionDescriptionDefault
debug
boolean
Debug mode. Writes debug messages to the pimatic log, if set to true.
false

Device Config Options

pimatic-gpio device config schemas

GpioSwitch

GpioSwitch config options
OptionDescriptionDefault
gpio
number
The GPIO pin
inverted
boolean
active low?
false
defaultState
boolean
State to set on startup, if not given, last state will be restored
debounceTimeout
number
Optional timeout in ms to software debounce the switch

GpioContact

GpioContact config options
OptionDescriptionDefault
gpio
number
The GPIO pin
inverted
boolean
LOW = closed?
false
debounceTimeout
number
Optional timeout in ms to software debounce the switch

GpioPresence

GpioPresence config options
OptionDescriptionDefault
gpio
number
The GPIO pin
inverted
boolean
LOW = present?
false
debounceTimeout
number
Optional timeout in ms to software debounce the switch
pimatic-gpio is written by Oliver Schneider (sweetpi)