Raspberry Pi GPIO


The rpi_gpio integration is the base for all related GPIO platforms in Home Assistant. There is no setup needed for the integration itself, for the platforms please check their corresponding pages.

Binary Sensor

The rpi_gpio binary sensor platform allows you to read sensor values of the GPIOs of your Raspberry Pi.

Configuration

To use your Raspberry Pi’s GPIO in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
binary_sensor:
  - platform: rpi_gpio
    ports:
      11: PIR Office
      12: PIR Bedroom

Configuration Variables

ports mapRequired

List of used ports.

port: name stringRequired

The port numbers (BCM mode pin numbers) and corresponding names.

bouncetime integer(Optional, default: 50)

The time in milliseconds for port debouncing.

invert_logic boolean(Optional)

If true, inverts the output logic to ACTIVE LOW.

Default:

false (ACTIVE HIGH)

pull_mode string(Optional, default: UP)

Type of internal pull resistor to use. Options are UP - pull-up resistor and DOWN - pull-down resistor.

For more details about the GPIO layout, visit the Wikipedia article about the Raspberry Pi.

Cover

The rpi_gpio cover platform allows you to use a Raspberry Pi to control your cover such as Garage doors.

It uses two pins on the Raspberry Pi.

  • The state_pin will detect if the cover is closed, and
  • the relay_pin will trigger the cover to open or close.

Although you do not need Andrews Hilliday’s software controller when you run Home Assistant, he has written clear instructions on how to hook your garage door and sensors up to your Raspberry Pi, which can be found here.

Configuration

To enable Raspberry Pi Covers in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
cover:
  - platform: rpi_gpio
    covers:
      - relay_pin: 10
        state_pin: 11

Configuration Variables

relay_time float(Optional, default: 0.2)

The time that the relay will be on for in seconds.

invert_relay boolean(Optional, default: false)

Invert the relay pin output so that it is active-high (True).

state_pull_mode string(Optional, default: UP)

The direction the State pin is pulling. It can be UP or DOWN.

invert_state boolean(Optional, default: false)

Invert the value of the State pin so that 0 means closed.

covers listRequired

List of your doors.

relay_pin integerRequired

The pin of your Raspberry Pi where the relay is connected.

state_pin integerRequired

The pin of your Raspberry Pi to retrieve the state.

name string(Optional)

The name to use in the frontend.

Full example

# Example configuration.yaml entry
cover:
  - platform: rpi_gpio
    relay_time: 0.2
    invert_relay: false
    state_pull_mode: 'UP'
    invert_state: true
    covers:
      - relay_pin: 10
        state_pin: 11
      - relay_pin: 12
        state_pin: 13
        name: 'Right door'

Remote Raspberry Pi Cover

If you don’t have Home Assistant running on your Raspberry Pi and you want to use it as a remote cover instead, there is a project called GarageQTPi that will work remotely with the MQTT Cover Component. Follow the GitHub instructions to install and configure GarageQTPi and once configured follow the Home Assistant instructions to configure the MQTT Cover.

Switch

The rpi_gpio switch platform allows you to control the GPIOs of your Raspberry Pi.

Configuration

To use your Raspberry Pi’s GPIO in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
switch:
  - platform: rpi_gpio
    ports:
      11: Fan Office
      12: Light Desk

Configuration Variables

ports listRequired

Array of used ports.

port integer | stringRequired

Port numbers and corresponding names (GPIO

invert_logic boolean(Optional, default: false)

If true, inverts the output logic to ACTIVE LOW.

For more details about the GPIO layout, visit the Wikipedia article about the Raspberry Pi.

Note that a pin managed by Home Assistant is expected to be exclusive to Home Assistant.

A common question is what does Port refer to, this number is the actual GPIO #, not the pin #. For example, if you have a relay connected to pin 11 its GPIO # is 17.

# Example configuration.yaml entry
switch:
  - platform: rpi_gpio
    ports:
      17: Speaker Relay