Skip to content

Instantly share code, notes, and snippets.

@funkfinger
Created April 26, 2026 03:21
Show Gist options
  • Select an option

  • Save funkfinger/ffebdf59d1484287fa8205831aaf8ece to your computer and use it in GitHub Desktop.

Select an option

Save funkfinger/ffebdf59d1484287fa8205831aaf8ece to your computer and use it in GitHub Desktop.
IKEA BILRESA 3-button scene toggle blueprint for Home Assistant
blueprint:
name: "IKEA BILRESA - 3-Button Scene Toggle (v1.0)"
description: >
Use the IKEA BILRESA's 3 mode buttons as scene toggles. For each channel,
pick a Scene. Click behavior:
- If ANY entity in the scene is currently 'on', turn them ALL off
(using homeassistant.turn_off, which works across light/switch/fan/etc).
- Otherwise, activate the scene with scene.turn_on.
The 3 channels map to the 3 button positions on the wheel. Leave a
channel's Scene field empty to disable that button.
Any multi_press_N (1/2/3) is treated as a click, so a single physical
press still toggles even when the BILRESA's Matter integration
occasionally misreports it as a double or triple press.
domain: automation
source_url: https://github.com/funkfinger/my-brain/blob/master/home-assistant/blueprints/bilresa-scenes.yaml
input:
remote_device:
name: "Remote Control"
description: "The IKEA BILRESA scroll wheel (Matter)."
selector:
device:
filter:
- manufacturer: "IKEA of Sweden"
model: "BILRESA scroll wheel"
header_1:
name: "Channel 1"
default: ""
selector:
constant:
value: ""
input_scene_1:
name: "Scene"
description: "Scene to toggle for channel 1's button. Leave empty to disable."
default:
selector:
entity:
domain: scene
header_2:
name: "Channel 2"
default: ""
selector:
constant:
value: ""
input_scene_2:
name: "Scene"
description: "Scene to toggle for channel 2's button. Leave empty to disable."
default:
selector:
entity:
domain: scene
header_3:
name: "Channel 3"
default: ""
selector:
constant:
value: ""
input_scene_3:
name: "Scene"
description: "Scene to toggle for channel 3's button. Leave empty to disable."
default:
selector:
entity:
domain: scene
mode: queued
max: 10
max_exceeded: silent
trigger_variables:
var_remote: !input remote_device
var_events: >
{{ device_entities(var_remote) | select('match', 'event\.') | sort | list }}
# Click event entities for each channel (button_3, button_6, button_9 on the BILRESA)
temp_kanal1_klick: "{{ var_events[2] if var_events | length > 2 else 'none' }}"
temp_kanal2_klick: "{{ var_events[5] if var_events | length > 5 else 'none' }}"
temp_kanal3_klick: "{{ var_events[8] if var_events | length > 8 else 'none' }}"
trigger:
- { trigger: event, event_type: state_changed, event_data: { entity_id: "{{ temp_kanal1_klick }}" }, id: trigger_kanal1_klick }
- { trigger: event, event_type: state_changed, event_data: { entity_id: "{{ temp_kanal2_klick }}" }, id: trigger_kanal2_klick }
- { trigger: event, event_type: state_changed, event_data: { entity_id: "{{ temp_kanal3_klick }}" }, id: trigger_kanal3_klick }
action:
- condition: template
value_template: "{{ trigger.event.data.new_state is not none }}"
- variables:
sc_1: !input input_scene_1
sc_2: !input input_scene_2
sc_3: !input input_scene_3
action_kanal_id: "{{ trigger.id.split('_')[1] }}"
curr_scene: "{% if action_kanal_id == 'kanal1' %}{{ sc_1 }}{% elif action_kanal_id == 'kanal2' %}{{ sc_2 }}{% else %}{{ sc_3 }}{% endif %}"
event_attr: "{{ trigger.event.data.new_state.attributes }}"
action_event_type: "{{ event_attr.event_type | default('none') }}"
# The scene's `entity_id` attribute is a list of entities the scene controls.
scene_entities: "{{ state_attr(curr_scene, 'entity_id') | default([]) }}"
# Treat any state other than off / unavailable / unknown as "active" so this
# works for switches, fans, lights, covers (open), etc.
any_on: >
{% set ns = namespace(active=false) %}
{% for e in scene_entities %}
{% if states(e) not in ['off', 'unavailable', 'unknown'] %}{% set ns.active = true %}{% endif %}
{% endfor %}
{{ ns.active }}
- choose:
- conditions:
- "{{ action_event_type in ['multi_press_1', 'multi_press_2', 'multi_press_3'] }}"
- "{{ curr_scene not in [none, '', 'none'] }}"
- "{{ scene_entities | count > 0 }}"
sequence:
- choose:
- conditions: "{{ any_on }}"
sequence:
- service: homeassistant.turn_off
target:
entity_id: "{{ scene_entities }}"
default:
- service: scene.turn_on
target:
entity_id: "{{ curr_scene }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment