Debouncing binary sensory

neat solution. however a simpler approach is outlined here

The linked post is three times longer so, just based on its length, I’ll ask you to summarize how it is a “simpler approach”.

Plus, a year has passed since this topic was written, and now in 0.113 it’s possible to use a completely different technique to ensure a script is only executed once (“debounced”).

although the post is long-ish on purpose, to help people understand without asking further questions, it does explain what is achieved visually.

and this isn’t about debouncing a script. its about debouncing a sensor (like a ping sensor) which emits ‘singular blips’ of binary state which needs to be transformed into longer spans of binary state. let me know if there’s something to achieve that in 0.113

Did you notice that the technique used in the linked post is the same one discussed in this topic?

The suggestion I had offered (using a timer) was an alternative approach and I even admitted in my post that it is best to use the other one that had been presented.

yes my bad. i noticed the approaches are more or less the same. i understand that the timer approach can have race conditions and the linked approach avoids that complexity.

anyway - thanks for telling me about the great new automation features in 0.113. i looked at them in detail and it seems like we have an even simpler approach now.

all one needs to do now is to:

  1. create an automation with the “restart” mode,
  2. which gets triggered by the binary sensor and,
  3. turns on another sensor (for keeping the active state),
  4. waits for a delay seconds
  5. turns off the state sensor

with the help of the “restart” mode, the state sensor stays activated upto delay-seconds from the last trigger time of the binary sensor (hence, debounced).

in fact there’s a lot more that can be done now using the new choose sequence feature (debounce multiple binary sensors together based on some if-else-if-else condition, what have you).

thanks @123