Last active
June 23, 2024 06:17
-
-
Save KoalaBear84/da51c5ae838732651fa8259c7316724b to your computer and use it in GitHub Desktop.
ZHA - Moes Smart Knob for lights (without manufacturer lock)
This file contains 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: ZHA - Moes Smart Knob for lights | |
description: | | |
Control lights with a Moes Smart Knob. | |
Rotating left/right will change the brightness smoothly of the selected light. | |
Inspired from https://gist.github.com/seamus65/939a147634942dd885c8704334627f93 | |
domain: automation | |
input: | |
remote: | |
name: Remote | |
description: Moes Knob to use | |
selector: | |
device: | |
integration: zha | |
model: TS004F | |
light: | |
name: Light(s) | |
description: The light(s) to control | |
selector: | |
target: | |
entity: | |
domain: light | |
speed: | |
name: Speed | |
description: Stepping speed | |
default: 50 | |
selector: | |
number: | |
min: 0 | |
max: 100 | |
unit_of_measurement: "%" | |
source_url: https://gist.github.com/Salamandar/325a6aa487003f7e55375751daea58b3 | |
mode: queued | |
max_exceeded: silent | |
max: 3 | |
trigger: | |
- platform: event | |
event_type: zha_event | |
event_data: | |
device_id: !input 'remote' | |
action: | |
- variables: | |
speed: !input 'speed' | |
the_light: !input 'light' | |
command: > | |
{{ trigger.event.data.command }} | |
dir: > | |
{% set command = trigger.event.data.command %} | |
{% set mode = trigger.event.data.params.get('step_mode', None) %} | |
{% if command == 'step' %} | |
{% if mode == 0 %} 1 {% elif mode == 1 %} -1 {% endif %} | |
{% elif command == 'step_color_temp' %} | |
{% if mode == 1 %} 1 {% elif mode == 3 %} -1 {% endif %} | |
{% endif %} | |
step: > | |
{{ trigger.event.data.params.get('step_size', 0) * speed / 100 }} | |
transition: > | |
{{ trigger.event.data.params.get('transition_time', 0) * speed / 100 }} | |
- choose: | |
- conditions: | |
- '{{ command == ''toggle'' }}' | |
sequence: | |
- service_template: light.toggle | |
target: '{{the_light}}' | |
- conditions: | |
- '{{ command == ''step'' }}' | |
sequence: | |
- service_template: light.turn_on | |
target: '{{the_light}}' | |
data_template: | |
brightness_step_pct: '{{ dir * step }}' | |
transition: '{{ transition }}' | |
# Unsupported, see https://community.home-assistant.io/t/provide-a-color-temp-step-for-light-turn-on/584595 | |
- conditions: | |
- '{{ command == ''step_color_temp'' }}' | |
sequence: [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment