Automation pHAT and Home Assistant



I recently purchased my first (and likely not my last!) Pimoroni product: an Automation pHAT. I was tinkering with it and a Pi Zero W with a PiNoir camera to make a garage door controller. It was pretty easy to set up a simple configuration with a reed switch to tell if the door was closed, use the relay to control the garage door opener, and set the camera up with motion-mmal for alerts.

I recently discovered Home Assistant, and started setting that up on a rPi 2 b. Somewhere along the way I got the bright idea to combine the two projects. I was able to get the relay working natively within Home Assistant using the instructions at Essentially I just added a section to my configuration file that tells the software to use GPIO 16 as a switch. Doing so added a switch to the Home Assistant GUI, and clicking it toggles the relay. Couldn’t be simpler, really. I can even add it to automations and easily control it from my phone.

I’m hoping to get some help doing something similar using the three input channels on GPIO 26 (input 1), 20 (input 2), and 21 (input 3) on the pHAT. I’m wondering if I can use them as binary sensors using the instructions at I did try just adding the three GPIOs as sensors, but Home Assistant always thinks they are on, no matter what I do to change the physical state of the inputs.

Does anyone have any ideas?


If you run automation pHat “” example does it see then input changes you are doing?


Just to test whether the inputs are working or not? Yes, the inputs work fine using the script.


Have you played with the “pull_mode” and “invert_logic” parameters?

Since the inputs on Automation HAT involve 24v tolerant protection circuit they are, unlike how you might traditionally wire a button, not inverted.

Looks like the binary_sensor is, by default, pulled “UP” and “ACTIVE HIGH”. You probably want it to be pulled down instead.


I hadn’t yet, but did just now. They work! If anyone is wondering in the future, the config that I used is:

      - platform: rpi_gpio
          26: pimoroni_1
          20: pimoroni_2
          21: pimoroni_3
        pull_mode: "DOWN"

For the relay it was even simpler:

      - platform: rpi_gpio
          16: pimoroni_relay

The pimoroni_ portions of the config are just labels, and can be changed to whatever is desired.

The screw terminals make it so easy to wire things up compared to doing everything manually. This is a great little board, at a great price.