Skip to content
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

Correct double-click detection logic #676

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

danleongjy
Copy link

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

  • Corrects logic for detecting virtual double-presses, so that it will only register double-presses if the same button was pressed twice within the helper_double_press_delay. The button's behaviour may change from what end-users previously expected.
  • Previously, any double-press writes "a": "double_press" to helper_last_controller_event. This PR adjusts helper_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 of helper_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 variable last_controller_event, then helper_last_controller_event is updated to the new trigger_action. Finally, the check for double-press uses the condition trigger_action | string in states(helper_last_controller_event). This effectively checks that trigger_action is in itself. As a result, if any two buttons are pressed within helper_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 to trigger_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*

  • I followed sections of the Contribution Guidelines relevant to changes I'm proposing.
  • I properly tested proposed changes on my system and confirm that they are working as expected.
  • I formatted files with Prettier using the command npm run format before submitting my Pull Request.

Copy link
Contributor

Hey @danleongjy, thank you so much for your contribution! 🚀

🔄 We're currently running a few checks to make sure that everything is great with your contribution.
If further actions need to be performed before your contribution can be reviewed, additional guidance will be provided to you in the next comment.

Results are coming soon, stay tuned!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug - Double-press triggers when any 2 buttons are pressed within the double-press delay
1 participant