Correct double-click detection logic #676
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for taking the time to work on a Pull Request. Your contribution is really appreciated! 🎉
Please don't delete any part of the template, since keeping the provided structure will help maintainers to review your work more rapidly.
Sections marked as * are required and need to be filled in.
Breaking change
helper_double_press_delay
. The button's behaviour may change from what end-users previously expected."a": "double_press"
tohelper_last_controller_event
. This PR adjustshelper_last_controller_event
to identify which button was double-pressed (eg."a": "double_press_up"
). Users implementing automations that look for"a": "double_press"
in the state ofhelper_last_controller_event
need to adjust their automations.Proposed change*
There is an issue with the logic for checking for virtual double-presses. First, the old state of the
helper_last_controller_event
is saved to variablelast_controller_event
, thenhelper_last_controller_event
is updated to the newtrigger_action
. Finally, the check for double-press uses the conditiontrigger_action | string in states(helper_last_controller_event)
. This effectively checks thattrigger_action
is in itself. As a result, if any two buttons are pressed withinhelper_double_press_delay
, a double-press action is detected, even if they are different buttons. Which double-press action is fired depends on which is the first one exposed. Changing the condition totrigger_action | string == last_controller_event
reflects the intended logic correctly and results in the intended behaviour.To enable better tracking of which button was double-pressed, the value pushed to
helper_last_controller_event
is also adjusted to be button-specific.Tested for E1810, E1743, E1766, E1812 and E2001/2002
Closes #643
Checklist*
npm run format
before submitting my Pull Request.