From 9e3c7701789f34cb9c7ab3b872d48d4b45229c02 Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Fri, 2 Oct 2026 23:15:32 +0100 Subject: [PATCH] Treat rotate followed by immediate stop rotate as a single click with Aqara H2 EU dimmer --- aqara-h2-eu-dimmer-z2m-light-control.yaml | 50 ++++++++++++++++++----- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/aqara-h2-eu-dimmer-z2m-light-control.yaml b/aqara-h2-eu-dimmer-z2m-light-control.yaml index 0ad92f2..d3c0e08 100644 --- a/aqara-h2-eu-dimmer-z2m-light-control.yaml +++ b/aqara-h2-eu-dimmer-z2m-light-control.yaml @@ -210,14 +210,42 @@ action: - condition: template value_template: "{{ action_type == 'rotation' }}" sequence: - # Filter out accidental micro-rotations (knocks) below the deadzone - - condition: template - value_template: "{{ (raw_angle | abs) >= (deadzone | float(0)) }}" - # Only fire the turn_on service if there was a registrable angle change - - 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 \ No newline at end of file + - choose: + # A click can occasionally appear as a small rotation followed + # immediately by stop_rotating. Only treat it as a single press + # if the stop_rotating packet actually follows. + - conditions: + - condition: template + value_template: "{{ (raw_angle | abs) < (deadzone | float(0)) }}" + sequence: + - wait_for_trigger: + - platform: mqtt + topic: !input mqtt_topic + payload: "stop_rotating" + value_template: "{{ value_json.action | default('') }}" + timeout: + milliseconds: 500 + continue_on_timeout: false + + - choose: + - conditions: + - condition: template + value_template: "{{ enable_toggle }}" + sequence: + - service: light.toggle + target: !input target_light + + - choose: + - conditions: [] + sequence: !input single_press_action + + # Normal rotation above the configured deadzone. + default: + # Only fire the turn_on service if there was a registrable angle change + - 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 \ No newline at end of file