-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
on_multi_click timings: allow one timing to cancel others #985
Comments
Please add this feature! My use case is a little different. In my home all switches are click type, but when you push and clicks the state holds. I tried to program on multiclick action but without this kind of feature is almost imposible to make it work, because when I push it 2 times for example to do a double click action then OFF state is hold and single click is triggered too. You can check in this verbose log:
This is the code (ignore the invalidation_cooldown, just trying [for me invalidation cooldown when one trigger success would make more sense]):
Thank you in advance. |
I need something similar, only I don't want all other timings to be cancelled, but just one specific timing. I found that this can be done with a very small change to the codebase. I added one method called id(id_of_trigger_to_be_cancelled).cancel(); The only downside is that I can do this only on triggers that have been defined above the line with the lambda, so it could currently not be used to e.g. have triggers mutually cancel each other. Currently I can't think of a use case for this either, but maybe there is one. Also, it means you are not free regarding the order of the triggers in your YAML. So if somebody can point me in the right direction to fix this (e.g. by changing code generation to declare all the id-variables first), I would be grateful. I will create a pull request with my small change, maybe it will also help someone else. |
Describe the problem you have/What new integration you would like
When multiple
on_multi_click
binary sensor timings are defined and a click-sequence is pressed, several multi click trigger candidates may still be valid at a given time because their timing pattern is still met but not yet complete.If one multi-click timing sequence is complete and valid, it would be great if there would be a way to cancel other timings that may still be pending (incomplete) in order to prevent them from firing.
E.g. an optional
- priority
setting in- timing
(at the same level of- ON
and- OFF
) could be used to cancel all other pending incomplete multi_click timings with a lower priority. As a probably more light-weight alternative, a- cancel_others
option would also be sufficient.This would allow much more flexible timings.
Please describe your use case for this integration and alternatives you've tried:
E.g. the example in the documentation https://esphome.io/components/binary_sensor/index.html#on-multi-click has to use different
OFF
timings to differentiate.In my use case, I'd like to fire button actions during button press without having to wait for a certain time of button release.
Additional context
I am currently trying to achieve the same using a global button_cooldown variable that is set by the first timing that fires and checked by subsequent timings that I want to invalidate if the first one had fired. However this is quite cumbersome and error prone.
The text was updated successfully, but these errors were encountered: