How to a trigger GPIO on Raspeberry Pi with a PIR sensor

I am new with HA and I cannot make the following to work.
I want to trigger a relay connected to the Raspberry Pi GPIO with a PIR sensor on a ESP8266.
I have the relay as a switch on the dashboard and working OK.

This is what I have so far.

On configuration.yaml I have the following:

switch:
  - platform: rpi_gpio
    switches:
      - port: 20
        name: `Relay 1`
        unique_id: `pi_gpio_20`
        invert_logic: true
ESP Wemos D1 with PIR sensor yaml:

binary_sensor:
  - platform: gpio
    pin: D6
    name: `PIR Sensor`
    device_class: motion

switch:
  - platform: restart
    name: `PIR Sensor Restart`

Are you aware that the RPi GPIO integration was depreciated and moved to a custom integration?

This means many people (including myself) moved from RPi GPIO to Tasmota or ESPhome; less users means maintaining the GPIO integration may become an issue. I get the pain - my project needed a v2 complete with new hardware, new 3d printed case, and new software. :slightly_frowning_face:

What are you trying to achieve please?

If you want a PIR sensor and controlled relay, my suggestion would be to avoid RPi GPIO and simply use the ESP8266 with ESPhome.

For many applications, the cost of parts is higher than buying a ready-made Sonoff or Shelly module and flashing with ESPhome / Tasmota (e.g. convenient, safe mains powered mains relays). Just be careful when adding sensors as these devices use mains-referenced power supplies.

If this helps, :heart: this post!

2 Likes

Thanks for the info, I was aware of the RPi GPIO was deprecated but tried to see if this was possible. I will move the relay to ESPHome.