Last active
August 25, 2025 09:08
-
-
Save Emanuele-Spatola/a03211634fed1e8847186f768685bc55 to your computer and use it in GitHub Desktop.
Control on/off and brightness of a light using a Zigbee smart knob through Zigbee2MQTT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: "Z2M Smart Knob Light Control ZG-101Z/D (MQTT Device Triggers)" | |
| description: "Control a light with a Zigbee smart knob discovered via Zigbee2MQTT using MQTT device triggers. Supports single press (toggle), rotate left/right (brightness step), and optional double press (run script)." | |
| domain: automation | |
| input: | |
| remote_device: | |
| name: Zigbee2MQTT Device | |
| description: "Pick the Zigbee2MQTT device (from the MQTT integration) that emits action events." | |
| selector: | |
| device: | |
| integration: mqtt | |
| light_target: | |
| name: Target Light | |
| description: "Select the light to control." | |
| selector: | |
| entity: | |
| domain: light | |
| brightness_step: | |
| name: Brightness Step Percentage | |
| description: "Percentage of brightness change per rotation step." | |
| default: 10 | |
| selector: | |
| number: | |
| min: 1 | |
| max: 50 | |
| unit_of_measurement: "%" | |
| double_press_script: | |
| name: Script on Double Press (optional) | |
| description: "Script to execute on a double press. Leave empty to do nothing." | |
| default: "" | |
| selector: | |
| entity: | |
| domain: script | |
| # 'queued' ensures every rotation step is applied in order; increase 'max' if you spin very fast. | |
| mode: queued | |
| max: 30 | |
| trigger: | |
| # Single press → Toggle light | |
| - platform: device | |
| domain: mqtt | |
| device_id: !input remote_device | |
| type: action | |
| subtype: single | |
| id: toggle | |
| # Rotate left → Decrease brightness | |
| - platform: device | |
| domain: mqtt | |
| device_id: !input remote_device | |
| type: action | |
| subtype: rotate_left | |
| id: decrease | |
| # Rotate right → Increase brightness | |
| - platform: device | |
| domain: mqtt | |
| device_id: !input remote_device | |
| type: action | |
| subtype: rotate_right | |
| id: increase | |
| # Double press → Optional script | |
| - platform: device | |
| domain: mqtt | |
| device_id: !input remote_device | |
| type: action | |
| subtype: double | |
| id: double | |
| action: | |
| - choose: | |
| # Single press → Toggle light | |
| - conditions: | |
| - condition: trigger | |
| id: toggle | |
| sequence: | |
| - service: light.toggle | |
| target: | |
| entity_id: !input light_target | |
| # Rotate left → Decrease brightness | |
| - conditions: | |
| - condition: trigger | |
| id: decrease | |
| sequence: | |
| - variables: | |
| step: !input brightness_step | |
| - service: light.turn_on | |
| target: | |
| entity_id: !input light_target | |
| data: | |
| # Negative step decreases brightness | |
| brightness_step_pct: "{{ (0 - (step | int)) | int }}" | |
| # Rotate right → Increase brightness | |
| - conditions: | |
| - condition: trigger | |
| id: increase | |
| sequence: | |
| - variables: | |
| step: !input brightness_step | |
| - service: light.turn_on | |
| target: | |
| entity_id: !input light_target | |
| data: | |
| # Positive step increases brightness | |
| brightness_step_pct: "{{ (step | int) }}" | |
| # Double press → Run script only if provided (no fallback) | |
| - conditions: | |
| - condition: trigger | |
| id: double | |
| sequence: | |
| - condition: template | |
| value_template: "{{ double_press_script is not none and double_press_script != '' }}" | |
| - service: script.turn_on | |
| target: | |
| entity_id: !input double_press_script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment