Created
February 7, 2025 12:29
-
-
Save kanedo/913217eb8ae2040a48b63afa57161456 to your computer and use it in GitHub Desktop.
Blueprint: ZHA - IKEA five button remote for lights with majority voting
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
blueprint: | |
name: ZHA - IKEA five button remote for lights with majority voting | |
description: 'Control lights with an IKEA five button remote (the round ones). | |
The middle "on" button, toggle the lights on/off to the last set brightness | |
based on the majorities state. | |
Dim up/down buttons will change the brightness smoothly and can be pressed | |
and hold until the brightness is satisfactory. | |
The "left" and "right" buttons can be assigned to a short and long button | |
press action. This allows you to assign, e.g., a scene or anything else. | |
based on https://community.home-assistant.io/t/zha-ikea-five-button-remote-for-lights/253804 | |
' | |
domain: automation | |
input: | |
remote: | |
name: Remote | |
description: IKEA remote to use | |
selector: | |
device: | |
integration: zha | |
manufacturer: IKEA of Sweden | |
model: TRADFRI remote control | |
light: | |
name: Light(s) | |
description: The light(s) to control | |
selector: | |
target: | |
entity: | |
domain: light | |
force_brightness: | |
name: Force turn on brightness | |
description: 'Force the brightness to the set level below, when the "on" button | |
on the remote is pushed and lights turn on. | |
' | |
default: false | |
selector: | |
boolean: {} | |
brightness: | |
name: Brightness | |
description: Brightness of the light(s) when turning on | |
default: 50 | |
selector: | |
number: | |
min: 0.0 | |
max: 100.0 | |
mode: slider | |
step: 1.0 | |
unit_of_measurement: '%' | |
button_left_short: | |
name: Left button - short press | |
description: Action to run on short left button press | |
default: [] | |
selector: | |
action: {} | |
button_left_long: | |
name: Left button - long press | |
description: Action to run on long left button press | |
default: [] | |
selector: | |
action: {} | |
button_right_short: | |
name: Right button - short press | |
description: Action to run on short right button press | |
default: [] | |
selector: | |
action: {} | |
button_right_long: | |
name: Right button - long press | |
description: Action to run on long right button press | |
default: [] | |
selector: | |
action: {} | |
source_url: https://community.home-assistant.io/t/zha-ikea-five-button-remote-for-lights/253804 | |
mode: restart | |
max_exceeded: silent | |
variables: | |
force_brightness: !input 'force_brightness' | |
lights: !input 'light' | |
lights_on: '{{expand(states.light) | selectattr("state", "eq", "on") | selectattr("entity_id", "in", area_entities(lights.area_id)) | list}}' | |
lights_off: '{{expand(states.light) | selectattr("state", "eq", "off") | selectattr("entity_id", "in", area_entities(lights.area_id)) | list}}' | |
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 }}' | |
args: '{{ trigger.event.data.args }}' | |
- choose: | |
- conditions: | |
- '{{ command == ''toggle'' }}' | |
- '{{ cluster_id == 6 }}' | |
- '{{ endpoint_id == 1 }}' | |
sequence: | |
- choose: | |
- conditions: '{{ lights_on | count > lights_off | count }}' | |
sequence: | |
- service: light.turn_off | |
target: !input 'light' | |
data: | |
transition: 1 | |
default: | |
- choose: | |
- conditions: '{{ force_brightness }}' | |
sequence: | |
- service: light.turn_on | |
target: !input 'light' | |
data: | |
transition: 1 | |
brightness_pct: !input 'brightness' | |
default: | |
- service: light.turn_on | |
target: !input 'light' | |
data: | |
transition: 1 | |
- conditions: | |
- '{{ command == ''step_with_on_off'' }}' | |
- '{{ cluster_id == 8 }}' | |
- '{{ endpoint_id == 1 }}' | |
sequence: | |
- service: light.turn_on | |
target: !input 'light' | |
data: | |
brightness_step_pct: 10 | |
transition: 1 | |
- conditions: | |
- '{{ command == ''move_with_on_off'' }}' | |
- '{{ cluster_id == 8 }}' | |
- '{{ endpoint_id == 1 }}' | |
sequence: | |
- repeat: | |
count: 10 | |
sequence: | |
- service: light.turn_on | |
target: !input 'light' | |
data: | |
brightness_step_pct: 10 | |
transition: 1 | |
- delay: 1 | |
- conditions: | |
- '{{ command == ''step'' }}' | |
- '{{ cluster_id == 8 }}' | |
- '{{ endpoint_id == 1 }}' | |
sequence: | |
- service: light.turn_on | |
target: !input 'light' | |
data: | |
brightness_step_pct: -10 | |
transition: 1 | |
- conditions: | |
- '{{ command == ''move'' }}' | |
- '{{ cluster_id == 8 }}' | |
- '{{ endpoint_id == 1 }}' | |
sequence: | |
- repeat: | |
count: 10 | |
sequence: | |
- service: light.turn_on | |
target: !input 'light' | |
data: | |
brightness_step_pct: -10 | |
transition: 1 | |
- delay: 1 | |
- conditions: | |
- '{{ command == ''press'' }}' | |
- '{{ cluster_id == 5 }}' | |
- '{{ endpoint_id == 1 }}' | |
- '{{ args == [257, 13, 0] }}' | |
sequence: !input 'button_left_short' | |
- conditions: | |
- '{{ command == ''hold'' }}' | |
- '{{ cluster_id == 5 }}' | |
- '{{ endpoint_id == 1 }}' | |
- '{{ args == [3329, 0] }}' | |
sequence: !input 'button_left_long' | |
- conditions: | |
- '{{ command == ''press'' }}' | |
- '{{ cluster_id == 5 }}' | |
- '{{ endpoint_id == 1 }}' | |
- '{{ args == [256, 13, 0] }}' | |
sequence: !input 'button_right_short' | |
- conditions: | |
- '{{ command == ''hold'' }}' | |
- '{{ cluster_id == 5 }}' | |
- '{{ endpoint_id == 1 }}' | |
- '{{ args == [3328, 0] }}' | |
sequence: !input 'button_right_long' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment