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.

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",
  "gpio": 18 
}

Plugin Config Options

gpio config

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

GpioContact

GpioContact config options
OptionDescriptionDefault
gpio
number
The gpio pin
inverted
boolean
LOW = closed?
false

GpioPresence

GpioPresence config options
OptionDescriptionDefault
gpio
number
The gpio pin
inverted
boolean
LOW = present?
false
pimatic-gpio is written by Oliver Schneider (sweetpi)