Slow response to GPIO inputs

Hi

I’m new to Home Assistant, I have managed to add a few integrations and test them successfully. I’m running hassio on a Raspberry Pi 3 B+.

I’m just trying my first automation, it’s very simple: I have a reed switch on my garage door connected between a GPIO pin/GND on the Pi and a WiFi switch socket controlling a set of lights on my porch. Garage door opens, porch lights switch on. Garage door closes, porch lights switch off. This is working correctly.

The issue I have is that there is a delay of several seconds (sometimes as much as 15 seconds) before Home Assistant detects that the GPIO has changed state. I’m not talking about the delay before the lights switch on/off, as this is pretty much instantaneous once Home Assistant detects the state change.

Does anyone have any suggestions on how the delay might be lowered or even eliminated? Are the GPIOs only scanned for state changes periodically and if so can the period be changed?

I originally had this setup working perfectly well using IFTTT, this was also delayed for obvious reasons which is why I decided to try Home Assistant.

Thanks in advance!

Here is my configuration: -

cover:
  - platform: rpi_gpio
    state_pull_mode: 'UP'
    invert_state: true
    covers:
      - relay_pin: 6
        state_pin: 26
        name: "Garage Front Door"

Duh! scan_interval! (always read the docs :wink:)

It seems that the default scan interval is set to 15 seconds.

Adding: -
scan_interval: 5
beneath the platform entry reduces the delay.

So I guess the question now is, how much of an impact does having a low delay make?

The GPIO binary sensor has changed recently. It used to be instantaneous but very unreliable. It’s still listed as a push device so should not rely on a polling interval. You might want to report the problem at that issue I linked to. Looks like the fix might have introduced another problem.

I moved over to a dedicated pi (two in fact) running raspbian and a GPIO to mqtt brigde for all my inputs. It has a virtually instant response and 100% reliability. https://github.com/flyte/pi-mqtt-gpio It’s configured with yaml.

1 Like

This sound very interesting and I think it might merge with my post.

The tinkerboard follow the RPI method to access the GPIO. I think it won’t be much a different. Just I’m not familiar with the BMC naming scheme.

Well I need to learn how I can set these additional programs on my docker installation. So the question it would be “how to add program in a docker system?”

I have almost the exact same setup and adding scan_interval

cover:
    - platform: rpi_gpio
      scan_interval: 5
      relay_time: 3
      state_pull_mode: 'UP'
      invert_state: true
      invert_relay: true
      covers:
        - name: 'Garage Overhead Door'
          relay_pin: 22
          state_pin: 23

didn’t change the response time at all, still takes 15 seconds for state changes.
I’m running 0.96.5

I recommend using NodeRED for getting GPIO inputs, it’s instant and can fire out MQTT or websocket messages to HA when the state changes.

Apparently ‘scan_interval’ is being phased out which may explain why it still takes 15 seconds:

These options are being phased out and are only available for single platform integrations.