Bug - Fix_multiple bugs incontroller blueprint for philips_324131092621 on Zigbee2MQTT #597
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.
Proposed change*
There are several bugs in the blueprint which make it unsuable when using Zigbee2MQTT.
I debugged the blueprint on my system and prepared this MR. Before submitting, I stumbled upon a few other PRs which address some of the issues exactly like I did, but not all of them.
Thus I still decided to go forward, so you can fix all issues with one single PR.
Merging this PR will solve the following issues:
#216
#406
#425
#457
#496
#541
#558
#576
and will make the following PRs obsolete:
#406
#542
#577
The fixes in more detail
Event mapping for zigbee2mqtt is wrong
There are two issues with that mapping. First of all, the events are sent with underscores, whereas the blueprint expects dashes. This prevents the script from working at all.
Secondly the event to listen for on short presses should be "on_press_release" and not "on_press". Listening to "on_press" triggers the script too early and too often. This causes all sorts of weird behaviour and a lot of race conditions. Listening to "on_press_release" solves this issue.
trigger_delta calculation is not working due to the regex not matching the helper value
The helper value looks like this:
The blueprint however, expects this:
I've modified the regular expression to make whitespaces optional and also accept other types of whitespace (tab, newline) and multiple consecutive whitespaces. This should also make it future proof.
Automation should not run on "on_press" events
As the event mapping is now using "on_press_release" events, the whole automation should not run for "on_press" events anymore. This also causes race conditions and weird unpredictable behaviour where double presses are not recognized for example.
I've changed the trigger condition to be false if such an event is received.
Checklist*
npm run format
before submitting my Pull Request.