Skip to content

Instantly share code, notes, and snippets.

@elupus
Last active September 30, 2022 20:37
Show Gist options
  • Save elupus/cad4a62cc714f1fd877e6b7adefd1940 to your computer and use it in GitHub Desktop.
Save elupus/cad4a62cc714f1fd877e6b7adefd1940 to your computer and use it in GitHub Desktop.
Blueprints for TS004F rotary encoders
blueprint:
name: TS004F Rotary Dimmer for Fans
description: Use as a relative dimmer
domain: automation
input:
rotary_device:
name: Source device
selector:
device:
integration: zha
model: TS004F
light:
name: Fan entities controlled
description: >
The light entity to use for toggle commands.
selector:
target:
entity:
domain: fan
mode: parallel
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input rotary_device
command: "step"
params:
step_mode: 0
id: "move_right"
- platform: event
event_type: zha_event
event_data:
device_id: !input rotary_device
command: "step"
params:
step_mode: 1
id: "move_left"
- platform: event
event_type: zha_event
event_data:
device_id: !input rotary_device
command: "toggle"
id: "toggle"
action:
- choose:
- conditions:
condition: trigger
id: "move_left"
sequence:
- service: fan.decrease_speed
target: !input light
data:
percentage_step: "{{ trigger.event.data.params.step_size / 2.0 }}"
- conditions:
condition: trigger
id: "move_right"
sequence:
- service: fan.increase_speed
target: !input light
data:
percentage_step: "{{ trigger.event.data.params.step_size / 2.0 }}"
- conditions:
condition: trigger
id: "toggle"
sequence:
- service: fan.toggle
target: !input light
blueprint:
name: TS004F Rotary Dimmer for Lights
description: Use as a relative dimmer
domain: automation
input:
rotary_device:
name: Source device
selector:
device:
integration: zha
model: TS004F
light:
name: Light entities controlled
description: >
The light entity to use for toggle commands.
selector:
target:
entity:
domain: light
mode: parallel
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input rotary_device
command: "step"
params:
step_mode: 0
id: "move_right"
- platform: event
event_type: zha_event
event_data:
device_id: !input rotary_device
command: "step"
params:
step_mode: 1
id: "move_left"
- platform: event
event_type: zha_event
event_data:
device_id: !input rotary_device
command: "toggle"
id: "toggle"
action:
- choose:
- conditions:
condition: trigger
id: "move_left"
sequence:
- service: light.turn_on
target: !input light
data:
brightness_step: "-{{ trigger.event.data.params.step_size }}"
- conditions:
condition: trigger
id: "move_right"
sequence:
- service: light.turn_on
target: !input light
data:
brightness_step: "{{ trigger.event.data.params.step_size }}"
- conditions:
condition: trigger
id: "toggle"
sequence:
- service: light.toggle
target: !input light
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment