Skip to content

Instantly share code, notes, and snippets.

@DarkCoder28
Created September 22, 2023 23:35
Show Gist options
  • Save DarkCoder28/319dcc6cdb7ce125403d5ba10bb7f9b4 to your computer and use it in GitHub Desktop.
Save DarkCoder28/319dcc6cdb7ce125403d5ba10bb7f9b4 to your computer and use it in GitHub Desktop.
blueprint:
name: IKEA STYRBAR 4 Toggles
description:
"Control lights with an IKEA STYRBAR. This blueprint turns the STYRBAR into 4 toggle buttons\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_up:
name: The light entity to control with the UP button.
description: The light entity to control.
selector:
entity:
domain: light
light_left:
name: The light entity to control with the LEFT button.
description: The light entity to control.
selector:
entity:
domain: light
light_right:
name: The light entity to control with the RIGHT button.
description: The light entity to control.
selector:
entity:
domain: light
light_down:
name: The light entity to control with the DOWN button.
description: The light entity to control.
selector:
entity:
domain: light
source_url: https://gist.github.com/DarkCoder28/319dcc6cdb7ce125403d5ba10bb7f9b4
mode: restart
max_exceeded: silent
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.toggle
target:
entity_id: !input "light_up"
- conditions: "{{ button_pressed == 'left' }}"
sequence:
- service: light.toggle
target:
entity_id: !input "light_left"
- conditions: "{{ button_pressed == 'right' }}"
sequence:
- service: light.toggle
target:
entity_id: !input "light_right"
- conditions: "{{ button_pressed == 'off' }}"
sequence:
- service: light.toggle
target:
entity_id: !input "light_down"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment