Skip to content

Instantly share code, notes, and snippets.

@kccricket
Last active October 4, 2021 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kccricket/182ad650643aed4864df850fc0617c84 to your computer and use it in GitHub Desktop.
Save kccricket/182ad650643aed4864df850fc0617c84 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint for Linkind 1-key Remote Control
blueprint:
name: ZHA - Linkind 1-key Remote Control
description: |
"Control your light(s) with Linkind 1-key Remote Control
Select the Linkind remote and your lights.
You can toggle the lights On/Off, or hold the button to dim the lights."
domain: automation
input:
remote:
name: Remote
description: The remote that will control the lights
selector:
device:
integration: zha
manufacturer: 'lk'
model: 'ZBT-DIMSwitch-D0001'
light:
name: Light
description: The lights that will be controlled
selector:
target:
entity:
domain: light
dim_direction_var:
name: Dimmer Direction Variable
description: input_number entity that will store the dim direction
selector:
entity:
domain: input_number
mode: restart
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 }}"
dim_direction: "{{ states(dim_direction_var)|int }}"
- choose:
- conditions:
- "{{ command == 'on' }}"
- "{{ cluster_id == 6 }}"
- "{{ endpoint_id == 1 }}"
sequence:
- service: light.turn_on
target: !input 'light'
data:
transition: 1
- conditions:
- "{{ command == 'off' }}"
- "{{ cluster_id == 6 }}"
- "{{ endpoint_id == 1 }}"
sequence:
- service: light.turn_off
target: !input 'light'
data:
transition: 1
- conditions:
- "{{ command == 'move' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
sequence:
- service: input_number.set_value
entity_id: !input dim_direction_var
data:
value: "{{ dim_direction * -1 }}"
- repeat:
while:
- condition: template
value_template: "{{ repeat.index < 10 }}"
sequence:
- service: light.turn_on
target: !input 'light'
data:
transition: 1
brightness_step_pct: "{{ dim_direction * 10 }}"
- delay: 1
- conditions:
- "{{ command == 'stop' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
sequence:
- service: light.turn_on
target: !input 'light'
@davide125
Copy link

dim_direction: "{{ states(dim_direction_var)|int }}" is hardcoding a variable named dim_direction_var and it won't work properly if that happens to not exist (because e.g. the one passed as input is named differently). It also prevents using more than one remote, as they'd all be sharing the same variable. Fixed in https://gist.github.com/davide125/7e5ebf1fa4bfaaac25169d239e079642 by reading it explicitly in with a !input directive.

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