Inhibit gpio binary sensor after onclick

Hi, it’s possible inhibit the binary sensor after click gpio push button.

pull down gpio → execute command → inhibit another execution for 3 sec.

this is the binary sensor

binary_sensor:
  - platform: gpio
    pin:
      number: P9
      inverted: True
    name: Button 1
    on_click:
      min_length: 150ms
      max_length: 250ms
      then:
        - switch.turn_on: relay1

That’s called throttling

I think a delayed_off: would probably work ok.

it’s for sensor

I just try, doesn’t work

settle maybe?

I don’t understand howto use it

You could use template binary sensor and update it when ever you want in your code.

unfortunately I don’t have this skill

I try to find on web example or explain of that but I don’t find anything, could you help me?

You could use settle like this:

binary_sensor:
  - platform: gpio
    pin:
      number: P9
      inverted: True
    name: Button 1
	filters:
	  settle: 3s
    on_click:
      min_length: 150ms
      max_length: 250ms
      then:
        - switch.turn_on: relay1

This means that the 3 seconds inhibit period will be counted from the last button press, though, and not just from last successful button press. If you want the latter, you’ll probably have to measure times yourself in a lambda action.

Something along these lines:

time:
  - platform: sntp
    id: sntp_time

binary_sensor:
  - platform: gpio
    pin:
      number: P9
      inverted: True
    name: Button 1
    on_click:
      min_length: 150ms
      max_length: 250ms
      then:
        - lambda: |-
            const int INHIBIT_SECS = 3;
            static int next_click = 0;
            auto time = id(sntp_time).now();
            if ( time.timestamp > next_click ) {
              id(relay1).turn_on();
              next_click = time.timestamp + INHIBIT_SECS;
            }

thanks so much!
the lambda script work great.