Another attempted fix for H2 EU dimmer detecting stop_rotating instead of single press - use a timeout
This commit is contained in:
1 parent
4523bdce43
commit
87c2f61dad
1 file changed
+16
-2
@@ -117,13 +117,27 @@ action:
|
|||||||
# Safely extract payload variables directly from the MQTT JSON message
|
# Safely extract payload variables directly from the MQTT JSON message
|
||||||
payload: "{{ trigger.payload_json if trigger.payload_json is defined else {} }}"
|
payload: "{{ trigger.payload_json if trigger.payload_json is defined else {} }}"
|
||||||
raw_action_type: "{{ payload.action | default('') }}"
|
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: >
|
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
|
single
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ raw_action_type }}
|
{{ raw_action_type }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
raw_angle: "{{ payload.action_rotation_angle | default(0) | float(0) }}"
|
raw_angle: "{{ payload.action_rotation_angle | default(0) | float(0) }}"
|
||||||
|
|
||||||
# Pull inputs into variables so they can be safely evaluated in templates below
|
# Pull inputs into variables so they can be safely evaluated in templates below
|
||||||
|
|||||||
Reference in new issue
Block a user