Pi GPIO Binary Sesnsor

[Can I write SOLVED !? - at least it works for me :star_struck:]

The problem is evident, as in my case, when binary sensor has to notify the buzz of my intercom, which usually should be pushed for less than a second (it depends on how polite are the people :sweat_smile:) so Iā€™ve solved in this way:

  • Iā€™ve wrote a rest_command (with pergola.fabio support) to switch OFF the binary sensor and created the automation that works after 1 second that binary_sensor is on ON state. In this way:

CONFIG:


rest_command:
  off_bussata:
    url: https://YOURIPADDRESS:8123/api/states/binary_sensor.citofono
    method: POST
    headers:
      authorization: !secret my_sensor_secret_token
      content-type: 'application/json'
    payload: '{"state":"off"}'
    verify_ssl: false
    
binary_sensor:
    platform: rpi_gpio
    invert_logic: False
    ports:
      27: Citofono

AUTOMATIONS:

####################################################
#            START UP Home Assistant               #
####################################################      
- id: hassio-start
  alias: Home Assistant StartUp
#  initial_state: 'on'
  trigger:
    platform: homeassistant
    event: start
  action:
    service: rest_command.off_bussata
  initial_state: true
####################################################                                               
#        Notifica di Bussata al Citofono           #
####################################################    
- id: bussata;
  alias: Bussata
  trigger:
  - entity_id: binary_sensor.citofono
    platform: state
    from: 'off'
    to: 'on'
  action:
  - data:
      message: Hanno Citofonato
    service: notify.notifichetelegram
  - delay: '1'
  - service: rest_command.off_bussata
  initial_state: true

Hope this can be helpful for someone. Cheers!

I donā€™tā€™ believe ā€œsolvedā€ is appropriate as youā€™ve posted a workaround, not a fix for the underlying system.

people need a solution and in my case it is solvedā€¦ and with your response the only solution is an update of HA so, what are you talking about? in any case my question on ā€œSolvedā€ was ironic but it is evident that you did not get it. Iā€™ve done my goal and people like me who read this post now have a solution because there is this option without any hardware works, thatā€™s why Iā€™ve shared. Farewell

Iā€™m very new to HA, Pi, coding and home automation (like one week old). Iā€™m having the same problem on my very first sensor. I need the Pi GPIOā€™s to be reliable. Looks like Iā€™ll have to work around the issue before Iā€™ve even got any sensors working!
I thought I had a broken Pi so I clean installed Rasbian with Node-Red. It detects GPIO state changes just fine, so, like others, I conclude itā€™s a software issue not a hardware fault.

Consolidating similar/related tickets:
https://github.com/home-assistant/core/issues/10498
https://sourceforge.net/p/raspberry-gpio-python/tickets/143/
https://sourceforge.net/p/raspberry-gpio-python/tickets/157/

1 Like

I was having issues as well, so I tried the remote method (https://www.home-assistant.io/integrations/remote_rpi_gpio/) even tho on the same Pi and all works nicely with HA.

Interesting. Thank you for posting that!

What did you use for the IP address of your ā€œremoteā€ (actually local) Pi? Did you use its real external address, or localhost?

Maybe someone familiar with the code can explain why this would work differently. I wouldnā€™t have guessed it would, but Iā€™ve seen stranger things.

I use the local IP address of the Pi itself, I run HA in Docker so localhost probably would resolve to the container. For info, the Pi4 runs Raspbian (Buster).

Would this work also on a Raspberry Pi running Hassio directly?

I am facing the same problem of unreliable edge detection. My use case is for rain measurement - I have a measurement device with a reed switch that would provide a pulse every 1mm of rainfall. The signal will therefore be very short whenever the internal cup swaps from one side to another.

I would hope for a fix since the rpi_gpio approach was simple enough to fit my needs.

I use Raspbian, I doubt if HASSIO has the remote gpio daemon.

1 Like

Hey Tom,

Are you still using this for GPIO inputs?

Yes I am.