@Fallingaway24, thank you for taking the time to write a very thoughtful post. It is very much appreciated. But I think you are making some assumptions about what I’m doing which aren’t correct.
you already have the capability to combine all of these copy sensors and integrate them into your GPIO binary sensor like I’ve made an example of below.
While I admit that I didn’t try on_multi_click, I did try on_click (which is why it is in my test code that I posted, and not in the final code) but it did not do what I wanted. In your example, “ShortActive event” will only be logged if the signal was active for at least 2 seconds and at most 3 seconds, at the time that the signal went inactive. In other words, as the name implies, when a button is clicked for 2 to 3 seconds. I don’t want this, I want the “ShortActive” even to trigger as soon as the signal has been active for 2 seconds, regardless of when it becomes inactive. In my application, the signal will typically be active for 12 hours, and with on_click I wouldn’t get the ShortActive or even LongActive at all. I tried to explain this above, but apparently wasn’t clear.
The second part where you have 10s delay_on and 20s delay _on and one is inverted but not the other… I have no idea what you’re trying to do here, it doesn’t make sense to me
One is inverted and one is not because I want one to fire as soon as the signal as been active for 10 seconds, and I want the other to fire as soon as the signal has been inactive for 20 seconds.
but, if you want to explain what the goal is, then I’m sure a solution can be found.
I tried explaining it at the beginning of the first post:
I have an ESPHome node that has a binary sensor connected to a GPIO pin. I want to trigger different actions if the input has been active for various times, or inactive for various times. For example, I want to trigger four different automation actions:
- action A when the input has been ON for 2 seconds
- action B when the input has been ON for 15 seconds
- action C when the input has been OFF for 2 seconds
- action D when the input has been OFF for 15 minutes (no, this isn’t a typo, I don’t mean 15 seconds.)
And a little later on in that first post: (with added emphasis)
There is the on_click trigger, which allows setting minimum and maximum times, but this seems to be looking for the input to become active for a certain time, and then perform the action when the input becomes inactive, assuming that it’s been active for the correct time range. I don’t want this, I want the triggers to fire as soon as the input has been in the right state for the right time, and not when it hits the opposite state.
This is not a button being clicked, it is an actual binary sensor, basically an infrared beam detector. I want to know as soon as it has been active for a short time, and in addition I want to know if it has been inactive for a longer time. I also want the inverse: trigger when inactive for a short time, and trigger when inactive for a longer time.
It’s basically two independent debouncings off of the same input. One that triggers after a short time, and one that triggers after a longer time.
Looking at it again, perhaps I could’ve gone with only two copies. Instead of using the inverted option on two of them, perhaps adding a delayed_off filter and on_release action would’ve accomplished the same thing. I may try it if I have a reason to go into the code again. (I’m slightly hesitant to muck around with working code, i have other things to do.)
Instead of having 8 different copy sensors, you now have 1 sensor with 7-8 possible actions from the button timing. Is there a reason you don’t just add a couple of extra buttons instead of going this route?
I don’t have 8 copies, only 4, and maybe only 2. You say 7-8 actions from a button, but the issue is that this is NOT a button. It is a sensor and I can’t make it perform arbitrary timing. And I can’t add extra buttons because I only have the single output bit from the sensor.
In my experience, buttons like this don’t stay cool veryt long and you’ll hate having 1 button that requires push/hold and timing sequences. You’ll constantly trigger the wrong thing or you will get irritated at it because your on/off timing isn’t matching so the thing your trying to turn On, it won’t freaking turn on!
I completely agree with you! And I wouldn’t be going through this exercise if this was a button I was trying to manually trigger. But it’s not a button, and it’s not being clicked, I need to react when the steady state changes for different intervals.