Hello,
Here is my blueprint for using Sunricher SR-ZG2836D5-EU switches. This switch is very high quality and somewhat reminiscent of the HUE tap with its rotating dial. But I find that the buttons on this one make it more accessible to use. This blueprint allows you to use the buttons as you wish and the dial to vary the intensity of the selected light. This is the first scenario I am sharing, so I am open to any suggestions for improvement and/or modification.
blueprint:
name: Sunricher Rotary Controller (MQTT)
description: >
Advanced control for Sunricher rotary switch (SR-ZG2836D5-EU) via Zigbee2MQTT.
domain: automation
input:
mqtt_topic:
name: MQTT Topic
description: "The base topic of your device (e.g., zigbee2mqtt/Room_Switch)."
light_entity:
name: Main Light Entity
description: "Used as reference for brightness calculation"
selector:
entity:
domain: light
# --- Center Button Actions (Toggle) ---
action_on:
name: Toggle - Turn ON Action
description: "Actions to execute when the button is pressed and send ON."
default: []
selector:
action: {}
action_off:
name: Toggle - Turn OFF Action
description: "Actions to execute when the button is pressed and send OFF."
default: []
selector:
action: {}
# --- R1 to R4 Button Actions ---
action_r1:
name: Button R1 (Recall 1)
description: "Sequence of actions for Button 1."
default: []
selector:
action: {}
action_r2:
name: Button R2 (Recall 2)
description: "Sequence of actions for Button 2."
default: []
selector:
action: {}
action_r3:
name: Button R3 (Recall 3)
description: "Sequence of actions for Button 3."
default: []
selector:
action: {}
action_r4:
name: Button R4 (Recall 4)
description: "Sequence of actions for Button 4."
default: []
selector:
action: {}
trigger:
- platform: mqtt
topic: !input mqtt_topic
action:
- variables:
command: "{{ trigger.payload_json.action }}"
step_size: "{{ trigger.payload_json.action_step_size | default(10) | int }}"
target_light: !input light_entity
- choose:
# ------------------------------------------------------
# CENTER BUTTON LOGIC (SMART TOGGLE)
# ------------------------------------------------------
- conditions: "{{ command in ['on', 'off'] }}"
sequence:
- if:
- condition: template
value_template: "{{ is_state(target_light, 'off') }}"
then:
# Light is OFF -> Run ON actions
- choose: []
default: !input action_on
else:
# Light is ON -> Run OFF actions...
- choose: []
default: !input action_off
# ...and force the main light off just in case
- action: light.turn_off
target:
entity_id: !input light_entity
# ------------------------------------------------------
# RECALL BUTTONS (R1-R4)
# ------------------------------------------------------
- conditions: "{{ command == 'recall_1' }}"
sequence: !input action_r1
- conditions: "{{ command == 'recall_2' }}"
sequence: !input action_r2
- conditions: "{{ command == 'recall_3' }}"
sequence: !input action_r3
- conditions: "{{ command == 'recall_4' }}"
sequence: !input action_r4
# ------------------------------------------------------
# ROTATION LOGIC (DIMMING)
# ------------------------------------------------------
- conditions: "{{ command in ['brightness_step_up', 'brightness_step_down'] }}"
sequence:
- variables:
current_brightness: "{{ state_attr(target_light, 'brightness') | int(0) }}"
target_brightness: >
{% if command == 'brightness_step_up' %}
{{ current_brightness + step_size }}
{% else %}
{{ current_brightness - step_size }}
{% endif %}
- choose:
- conditions: "{{ target_brightness <= 0 }}"
sequence:
- action: light.turn_off
target:
entity_id: !input light_entity
- conditions: "{{ target_brightness > 0 }}"
sequence:
- action: light.turn_on
target:
entity_id: !input light_entity
data:
brightness: "{{ [target_brightness, 255] | min }}"
mode: restart