Allow small rotations to trigger brightness changes with H2 EU dimmer

This commit is contained in:
mg committed 2026-10-02 23:19:42 +01:00
1 parent 9e3c770178
commit 490d60adc0
1 file changed
+28 -13
+28 -13
View File
@@ -44,7 +44,7 @@ blueprint:
rotation_deadzone: rotation_deadzone:
name: Rotation Deadzone (Anti-knock) name: Rotation Deadzone (Anti-knock)
description: The minimum rotation angle (in degrees) required to trigger a dimming action. Increase this if you accidentally dim the lights when clicking the knob. description: The rotation angle below which the blueprint briefly waits to determine whether the event was actually a single click.
default: 20 default: 20
selector: selector:
number: number:
@@ -126,11 +126,8 @@ action:
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('') }}"
# Time since the previous MQTT event triggered this automation. # Time since the previous real MQTT action event.
# Genuine stop_rotating events immediately follow rotation events. # Null/missing action packets are filtered at the trigger above.
# The H2 bug emits a stray stop_rotating after the device has been idle.
# Null/missing action packets are filtered at the MQTT trigger above,
# so only genuine action events affect this timer.
idle_seconds: > idle_seconds: >
{{ as_timestamp(now()) - {{ as_timestamp(now()) -
as_timestamp( as_timestamp(
@@ -211,9 +208,9 @@ action:
value_template: "{{ action_type == 'rotation' }}" value_template: "{{ action_type == 'rotation' }}"
sequence: sequence:
- choose: - choose:
# A click can occasionally appear as a small rotation followed # Small rotations may actually be a misreported single click.
# immediately by stop_rotating. Only treat it as a single press # Wait briefly for the stop_rotating packet that accompanies
# if the stop_rotating packet actually follows. # the H2's erroneous rotation -> stop_rotating click sequence.
- conditions: - conditions:
- condition: template - condition: template
value_template: "{{ (raw_angle | abs) < (deadzone | float(0)) }}" value_template: "{{ (raw_angle | abs) < (deadzone | float(0)) }}"
@@ -224,9 +221,16 @@ action:
payload: "stop_rotating" payload: "stop_rotating"
value_template: "{{ value_json.action | default('') }}" value_template: "{{ value_json.action | default('') }}"
timeout: timeout:
milliseconds: 500 milliseconds: 300
continue_on_timeout: false continue_on_timeout: true
- choose:
# stop_rotating arrived within the click window:
# treat the small rotation as a single press.
- conditions:
- condition: template
value_template: "{{ wait.completed }}"
sequence:
- choose: - choose:
- conditions: - conditions:
- condition: template - condition: template
@@ -239,9 +243,20 @@ action:
- conditions: [] - conditions: []
sequence: !input single_press_action sequence: !input single_press_action
# Normal rotation above the configured deadzone. # No stop_rotating within the click window:
# this was a genuine small rotation, so apply it.
default:
- condition: template
value_template: "{{ scaled_step != 0 }}"
- service: light.turn_on
target: !input target_light
data:
brightness_step_pct: "{{ scaled_step }}"
transition: !input dim_transition
# Rotation exceeds the deadzone, so it is unambiguously a
# genuine rotation and can be processed immediately.
default: default:
# Only fire the turn_on service if there was a registrable angle change
- condition: template - condition: template
value_template: "{{ scaled_step != 0 }}" value_template: "{{ scaled_step != 0 }}"
- service: light.turn_on - service: light.turn_on