Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save gonzaloalbito/3dc06702e941e08298ea9bfade731731 to your computer and use it in GitHub Desktop.
Save gonzaloalbito/3dc06702e941e08298ea9bfade731731 to your computer and use it in GitHub Desktop.
blueprint:
name: ZHA - Moes Smart Knob for lights
description: 'Control lights with a Moes Smart Knob.
You can set functions for a single press. This allows you to assign, e.g., a scene
or anything else.
Rotating left/right will change the brightness smoothly of the selected light.
Not all functionality of the device is available at time of writing, e.g. double
press, long press and press and rotate.
Original blueprint by seamus65 (https://gist.github.com/seamus65/939a147634942dd885c8704334627f93).
Improved by GonzaloAlbito (https://gist.github.com/gonzaloalbito/3dc06702e941e08298ea9bfade731731).
Version 2022-11-15.'
domain: automation
input:
remote:
name: Remote
description: Moes Knob to use
selector:
device:
integration: zha
manufacturer: _TZ3000_qja6nq5z
model: TS004F
multiple: false
light:
name: Light(s)
description: The light(s) to control
selector:
target:
entity:
domain: light
step_percent:
name: Light step
description: Light pecent change for each knob step
selector:
number:
mode: slider
min: 0
max: 100
unit_of_measurement: "%"
default: 20
press_light:
name: Pressed light(s)
description: The light(s) to control when pressed
selector:
target:
entity:
domain: light
press_step_percent:
name: Pressed light step
description: Light pecent change for each knob step when pressed
selector:
number:
mode: slider
min: 0
max: 100
unit_of_measurement: "%"
default: 5
single_press:
name: Single press
description: Action to run on single press
default: []
selector:
action: {}
source_url: https://gist.github.com/gonzaloalbito/3dc06702e941e08298ea9bfade731731
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input remote
action:
- variables:
command: '{{ trigger.event.data.command }}'
cluster_id: '{{ trigger.event.data.cluster_id }}'
endpoint_id: '{{ trigger.event.data.endpoint_id }}'
mode: '{% if command != ''toggle'' %} {{ trigger.event.data.args[0] }} {% endif %}'
steps: '{% if command != ''toggle'' %} {{ (trigger.event.data.args[1] / 12.5 ) | int }} {% endif %}'
step_percent: !input step_percent
press_step_percent: !input press_step_percent
- choose:
- conditions:
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 1 }}'
- '{{ command == ''toggle'' }}'
sequence: !input single_press
- conditions:
- '{{ cluster_id == 8 }}'
- '{{ endpoint_id == 1 }}'
- '{{ command == ''step'' }}'
- '{{ mode == ''StepMode.Up'' }}'
sequence:
- repeat:
while:
- condition: template
value_template: '{{ repeat.index < 2 }}'
sequence:
- service_template: light.turn_on
target: !input light
data_template:
brightness_step_pct: '{{ step_percent * steps }}'
transition: 0.5
- conditions:
- '{{ cluster_id == 8 }}'
- '{{ endpoint_id == 1 }}'
- '{{ command == ''step'' }}'
- '{{ mode == ''StepMode.Down'' }}'
sequence:
- repeat:
while:
- condition: template
value_template: '{{ repeat.index < 2 }}'
sequence:
- service_template: light.turn_on
target: !input light
data_template:
brightness_step_pct: '-{{ step_percent * steps }}'
transition: 0.5
- conditions:
- '{{ cluster_id == 768 }}'
- '{{ endpoint_id == 1 }}'
- '{{ command == ''step_color_temp'' }}'
- '{{ mode == ''StepMode.Up'' }}'
sequence:
- repeat:
while:
- condition: template
value_template: '{{ repeat.index < 2 }}'
sequence:
- service_template: light.turn_on
target: !input press_light
data_template:
brightness_step_pct: '{{ press_step_percent * steps }}'
transition: 0.5
- conditions:
- '{{ cluster_id == 768 }}'
- '{{ endpoint_id == 1 }}'
- '{{ command == ''step_color_temp'' }}'
- '{{ mode == ''StepMode.Down'' }}'
sequence:
- repeat:
while:
- condition: template
value_template: '{{ repeat.index < 2 }}'
sequence:
- service_template: light.turn_on
target: !input press_light
data_template:
brightness_step_pct: '-{{ press_step_percent * steps }}'
transition: 0.5
@diggit
Copy link

diggit commented Nov 16, 2023

Hi,
my Livarno zigbee LED light turns off when dialed to 0%.
https://www.lidl.cz/p/livarno-home-zigbee-3-0-smart-home-stropni-led-svitidlo/p100358608
Would it be possible to somehow limit minimum value in this blueprint? I tried to set min: 0 to something higher but without effect.

@gonzaloalbito
Copy link
Author

Hi!
I think having the light off when brightness is at 0% is the default behavior for all light bulbs. At least all I have behave that way and it has some logic, because 0% brightness means 0%, so it should have no light at all.
That said, you could configure an automation in HA which is triggered when the bulb is at 0% so it bring it up at 1%, but I'm not pretty sure that will work.

@diggit
Copy link

diggit commented Dec 26, 2023

Yeah, my goal was to alter this blueprint so it does not happen. I tried altering value on lines 39 and 56 to non zero value, but it had no effect. Any idea what else should I change to achieve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment