Created
March 3, 2025 17:55
-
-
Save harmpter/8fd84bb3d9cc141e6eba880cc9da2959 to your computer and use it in GitHub Desktop.
harmpter's Zigbee rotary knob (MOES) macro
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
{% macro get_zigbee_rotary_info(data) %} | |
{#- harmpter's macro 1741019010 -#} | |
{#- allow both 'trigger' and 'trigger.event.data' as input -#} | |
{%- if data.command is not defined -%}{%- set data = data.event.data -%}{%- endif -%} | |
{%- if data.cluster_id==6 -%} | |
{{- 0.0 -}} | |
{%- elif data.cluster_id==8 -%} | |
{{- (1-data.params.step_mode*2) * (data.params.step_size-1)/12 -}} | |
{%- else -%} | |
{{- (2-data.params.step_mode) * (data.params.step_size-1)/17 -}} | |
{%- endif -%} | |
{% endmacro %} |
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
# example: changes brightness by +5 or -5 each step | |
action: | |
- alias: handle zigbee rotary knob | |
if: "{{ trigger.event.data.command == 'step' }}" # step | step_color_temp | toggle | |
then: | |
- alias: change brightness | |
action: light.turn_on | |
data: | |
entity_id: light.room | |
brightness_step_pct: >- | |
{% from 'macros.jinja' import get_zigbee_rotary_info as get %} | |
{{ get(trigger)|int * 5 }} | |
else: | |
- alias: change color temp | |
action: light.turn_on | |
data: | |
entity_id: light.room | |
color_temp_kelvin: >- | |
{% from 'macros.jinja' import get_zigbee_rotary_info as get %} | |
{{ get(trigger)|int * 100 + state_attr('light.room','color_temp_kelvin') }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment