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

Bug - Fix_multiple bugs incontroller blueprint for philips_324131092621 on Zigbee2MQTT #597

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,18 @@ variables:
button_down_long: [down_hold]
button_down_release: [down_long_release]
zigbee2mqtt:
button_on_short: [on-press]
button_on_long: [on-hold]
button_on_release: [on-hold-release]
button_off_short: [off-press]
button_off_long: [off-hold]
button_off_release: [off-hold-release]
button_up_short: [up-press]
button_up_long: [up-hold]
button_up_release: [up-hold-release]
button_down_short: [down-press]
button_down_long: [down-hold]
button_down_release: [down-hold-release]
button_on_short: [on_press_release]
button_on_long: [on_hold]
button_on_release: [on_hold_release]
button_off_short: [off_press_release]
button_off_long: [off_hold]
button_off_release: [off_hold_release]
button_up_short: [up_press_release]
button_up_long: [up_hold]
button_up_release: [up_hold_release]
button_down_short: [down_press_release]
button_down_long: [down_hold]
button_down_release: [down_hold_release]
# pre-choose actions for buttons based on configured integration
# no need to perform this task at automation runtime
button_on_short: '{{ actions_mapping[integration_id]["button_on_short"] }}'
Expand Down Expand Up @@ -380,7 +380,7 @@ condition:
{{ trigger.event.data.command }}
{%- endif -%}
{%- endset -%}
{{ trigger_action not in ["","None"] }}
{{ trigger_action not in ["","None", "on_press", "up_press", "down_press", "off_press"] }}
# only for zigbee2mqtt, check if the event is relative to a real state change, and not only some minor changes in the sensor attributes
# this is required since multiple state_changed events are fired for a single button press, with the result of the automation being triggered multiple times
- '{{ integration_id != "zigbee2mqtt" or trigger.event.data.new_state.state != trigger.event.data.old_state.state }}'
Expand All @@ -401,7 +401,8 @@ action:
{%- elif integration_id == "zha" -%}
{{ trigger.event.data.command }}
{%- endif -%}
trigger_delta: '{{ (as_timestamp(now()) - ((states(helper_last_controller_event) | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else as_timestamp("1970-01-01 00:00:00"))) * 1000 }}'
# helper_last_controller_event example: {"a":"on_press_release","t":1706926380.358825}
trigger_delta: '{{ (as_timestamp(now()) - ((states(helper_last_controller_event) | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match("^\{((\"a\":\s*\".*\"|\"t\":\s*\d+\.\d+)(,\s*)?){2}\}$")) else as_timestamp("1970-01-01 00:00:00"))) * 1000 }}'
# update helper
- service: input_text.set_value
data:
Expand Down Expand Up @@ -489,7 +490,7 @@ action:
- choose:
- conditions: []
sequence: !input action_button_on_release
- conditions: '{{ trigger_action | string in button_off_short }}'
- conditions: "{{ trigger_action | string in button_off_short }}"
sequence:
- choose:
# if double press event is enabled
Expand Down
Loading