Another attempted fix for H2 EU dimmer detecting stop_rotating instead of single press - use a timeout

This commit is contained in:
mg committed 2026-09-26 20:46:36 +01:00
1 parent 4523bdce43
commit 87c2f61dad
1 file changed
+17 -3
+17 -3
View File
@@ -117,13 +117,27 @@ action:
# Safely extract payload variables directly from the MQTT JSON message
payload: "{{ trigger.payload_json if trigger.payload_json is defined else {} }}"
raw_action_type: "{{ payload.action | default('') }}"
rotation_button_state: "{{ payload.action_rotation_button_state | default('') }}"
# Time since the previous MQTT event triggered this automation.
# Genuine stop_rotating events immediately follow rotation events.
# The H2 bug emits a stray stop_rotating after the device has been idle.
idle_seconds: >
{{ as_timestamp(now()) -
as_timestamp(
this.attributes.last_triggered
| default(as_datetime(0), true)
)
}}
# Work around the H2 occasionally reporting the first single press
# after being idle as stop_rotating.
action_type: >
{% if raw_action_type == 'stop_rotating' and rotation_button_state == 'pressed' %}
{% if raw_action_type == 'stop_rotating' and idle_seconds | float > 1 %}
single
{% else %}
{{ raw_action_type }}
{% endif %}
raw_angle: "{{ payload.action_rotation_angle | default(0) | float(0) }}"
# Pull inputs into variables so they can be safely evaluated in templates below
@@ -196,4 +210,4 @@ action:
target: !input target_light
data:
brightness_step_pct: "{{ scaled_step }}"
transition: !input dim_transition
transition: !input dim_transition