Skip to content

Instantly share code, notes, and snippets.

@Gr8z
Created July 1, 2026 12:14
Show Gist options
  • Select an option

  • Save Gr8z/db3dcd2d1a8954d7f65057d6515ae012 to your computer and use it in GitHub Desktop.

Select an option

Save Gr8z/db3dcd2d1a8954d7f65057d6515ae012 to your computer and use it in GitHub Desktop.
blueprint:
name: Aqara H2 Wireless Switch (2 gang) — 2 Lights + Dimming (Z2M MQTT)
description: >
Control two lights with an Aqara H2 wireless remote switch (2 gang) via
Zigbee2MQTT, using a raw MQTT trigger (reads `action` from the topic
payload).
Left rocker → Light 1, Right rocker → Light 2.
• Single click → toggle
• Double click → set to 100%
• Hold → dim one step (repeats while held; direction flips per fresh hold)
Setup:
• Enter the MQTT topic: zigbee2mqtt/<your switch friendly name>
• Set click_mode = "multi" in Z2M (needed for double + hold events).
domain: automation
input:
mqtt_topic:
name: MQTT topic
description: "e.g. zigbee2mqtt/H2 Switch Living Room"
selector:
text:
light_left:
name: Light 1 (Left rocker)
selector:
target:
entity:
domain: light
light_right:
name: Light 2 (Right rocker)
selector:
target:
entity:
domain: light
dim_step:
name: Dim step size (%)
default: 12
selector:
number:
min: 1
max: 25
step: 1
unit_of_measurement: "%"
mode: queued
max: 10
max_exceeded: silent
trigger:
- platform: mqtt
topic: !input mqtt_topic
variables:
action: "{{ trigger.payload_json.action }}"
dim_step: !input dim_step
condition:
- "{{ trigger.payload_json.action is defined and trigger.payload_json.action not in [None, ''] }}"
action:
- choose:
# ---------------- LEFT ROCKER → Light 1 ----------------
- conditions: "{{ action == 'single_left' }}"
sequence:
- service: light.toggle
target: !input light_left
- conditions: "{{ action == 'double_left' }}"
sequence:
- service: light.turn_on
target: !input light_left
data:
brightness_pct: 100
- conditions: "{{ action == 'hold_left' }}"
sequence:
- variables:
lt_ent: "{{ (light_left.entity_id if light_left.entity_id is string else light_left.entity_id[0]) }}"
- service: light.turn_on
target: !input light_left
data:
brightness_step_pct: >
{{ dim_step if (state_attr(lt_ent, 'brightness') or 0) < 128 else (dim_step * -1) }}
transition: 0.4
# ---------------- RIGHT ROCKER → Light 2 ----------------
- conditions: "{{ action == 'single_right' }}"
sequence:
- service: light.toggle
target: !input light_right
- conditions: "{{ action == 'double_right' }}"
sequence:
- service: light.turn_on
target: !input light_right
data:
brightness_pct: 100
- conditions: "{{ action == 'hold_right' }}"
sequence:
- variables:
rt_ent: "{{ (light_right.entity_id if light_right.entity_id is string else light_right.entity_id[0]) }}"
- service: light.turn_on
target: !input light_right
data:
brightness_step_pct: >
{{ dim_step if (state_attr(rt_ent, 'brightness') or 0) < 128 else (dim_step * -1) }}
transition: 0.4
# ---------------- BOTH ROCKERS ----------------
- conditions: "{{ action == 'single_both' }}"
sequence:
- service: light.toggle
target: !input light_left
- service: light.toggle
target: !input light_right
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment