Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save Gr8z/c07eed6c5eda4d55c8ca8cbf4b684149 to your computer and use it in GitHub Desktop.
blueprint:
name: Aqara H2 Wireless Switch (2 gang) — 2 Lights (Z2M MQTT)
description: >
Two lights via Aqara H2 wireless 2-gang switch over Zigbee2MQTT (raw MQTT trigger).
Left rocker → Light 1, Right rocker → Light 2.
• Single click → toggle on/off
• Double click → cycle brightness (25 → 50 → 75 → 100 → 25)
Setup: enter topic zigbee2mqtt/<friendly name>; set click_mode = "multi" in Z2M.
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
mode: queued
max: 10
max_exceeded: silent
trigger:
- platform: mqtt
topic: !input mqtt_topic
variables:
action: "{{ trigger.payload_json.action }}"
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:
- variables:
lt_ent: "{{ (light_left.entity_id if light_left.entity_id is string else light_left.entity_id[0]) }}"
cur: "{{ (state_attr(lt_ent, 'brightness') or 0) }}"
next_pct: >
{% set p = (cur / 255 * 100) | round(0) %}
{% if p < 25 %}25
{% elif p < 50 %}50
{% elif p < 75 %}75
{% elif p < 100 %}100
{% else %}25{% endif %}
- service: light.turn_on
target: !input light_left
data:
brightness_pct: "{{ next_pct | int }}"
transition: 0.4
# ---------------- RIGHT ROCKER → Light 2 ----------------
- conditions: "{{ action == 'single_right' }}"
sequence:
- service: light.toggle
target: !input light_right
- conditions: "{{ action == 'double_right' }}"
sequence:
- variables:
rt_ent: "{{ (light_right.entity_id if light_right.entity_id is string else light_right.entity_id[0]) }}"
cur: "{{ (state_attr(rt_ent, 'brightness') or 0) }}"
next_pct: >
{% set p = (cur / 255 * 100) | round(0) %}
{% if p < 25 %}25
{% elif p < 50 %}50
{% elif p < 75 %}75
{% elif p < 100 %}100
{% else %}25{% endif %}
- service: light.turn_on
target: !input light_right
data:
brightness_pct: "{{ next_pct | int }}"
transition: 0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment