Skip to content

Instantly share code, notes, and snippets.

@DarkCoder28
Last active September 9, 2023 18:13
Show Gist options
  • Save DarkCoder28/3ad483a37f65a415ca2fc56fb56dab96 to your computer and use it in GitHub Desktop.
Save DarkCoder28/3ad483a37f65a415ca2fc56fb56dab96 to your computer and use it in GitHub Desktop.
Home Assistant: Control lights with an IKEA STYRBAR
blueprint:
name: IKEA STYRBAR Dimmer Remote
description:
"Control lights with an IKEA STYRBAR.\n\n Blueprint\
\ Version: 1"
domain: automation
input:
remote:
name: IKEA STYRBAR
description: Pick an IKEA STYRBAR remote
selector:
device:
integration: zha
entity:
domain: sensor
device_class: battery
light:
name: The light entity to control.
description: The light entity to control; On will turn the light on, Right will brighten the light, Left will dim the light, Off will turn the light off.
selector:
entity:
domain: light
source_url: https://gist.github.com/DarkCoder28/3ad483a37f65a415ca2fc56fb56dab96
mode: restart
max_exceeded: silent
variables:
light: !input "light"
remote: !input "remote"
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input "remote"
cluster_id: 6
- platform: event
event_type: zha_event
event_data:
device_id: !input "remote"
cluster_id: 5
- platform: event
event_type: zha_event
event_data:
device_id: !input "remote"
cluster_id: 8
action:
- variables:
cluster: "{{ trigger.event.data.cluster_id }}"
lr_button: "{{ trigger.event.data.params.param1 }}"
command: "{{ trigger.event.data.command }}"
button_pressed: "{{ ('right' if lr_button == 256 else 'left') if cluster == 5 else (command) if cluster == 6 or cluster == 8 }}"
- choose:
- conditions: "{{ button_pressed == 'on' }}"
sequence:
- service: light.turn_on
target:
entity_id: !input "light"
data:
transition: 5
- conditions: "{{ button_pressed == 'stop_with_on_off' }}"
sequence:
- service: light.turn_on
target:
entity_id: !input "light"
data:
brightness_pct: 100
transition: 5
- conditions: "{{ button_pressed == 'left' }}"
sequence:
- service: light.turn_on
target:
entity_id: !input "light"
data:
brightness_step_pct: -10
- conditions: "{{ button_pressed == 'right' }}"
sequence:
- service: light.turn_on
target:
entity_id: !input "light"
data:
brightness_step_pct: 10
- conditions: "{{ button_pressed == 'off' }}"
sequence:
- service: light.turn_off
target:
entity_id: !input "light"
data:
transition: 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment