This is a blueprint for the IKEA Tradfri Styrbar 4 Buttons with switching assignments for each button.
If you are looking for an option to use the remote for different actions / lights which you can easily change, this is it.
You can specify the actions for 4 different states (State01 - State04). For each state you can select what each button function should do. (apart from left and right button press)
In that version you change the current activated state with left and right button press.
For knowing the current state you need to create a helper - input_select with the four options: State01, State02, State03 and State04.
Because I am quite new to home assistant I am happy for useful feedback for improving the code.
Blueprint Code
Click the badge to import this Blueprint: (needs Home Assistant Core that supports zigbee2mqtt)
Or import this Blueprint by using the forum topic URL:
blueprint:
name: 'Z2M IKEA styrbar universal'
description: "Blueprint for Ikea Remote Controls Styrbar - 4 Buttons. With Left and Right click you can switch the States.
Create a helper input_select with 4 States (State01, State02, State03, State04)"
domain: automation
source_url: https://community.home-assistant.io/t/zigbee2mqtt-ikea-tradfri-styrbar-4-buttons-universal-switch-for-4-different-states/520309
input:
remote:
name: Remote
description: IKEA Styrbar remote to use (e.g sensor.kitchen_remote_action)
selector:
entity:
integration: mqtt
domain: sensor
multiple: false
helper_selector:
name: Helper - active state
description: Helper for activated state. Create a helper input_select with 4 States (State01, State02, State03, State04)
selector:
entity:
domain: input_select
onR1:
name: On Button State 1
description: Action to run when SHORT press
default: []
selector:
action: {}
offR1:
name: Off Button State 1
description: Action to run when SHORT press
default: []
selector:
action: {}
on_longR1:
name: Brightness up Button State 1
description: Action to run when Long press
default: []
selector:
action: {}
off_longR1:
name: Brightness down Button State 1
description: Action to run when Long press
default: []
selector:
action: {}
right_longR1:
name: Right Hold Button State 1
description: Action to run when Long press
default: []
selector:
action: {}
left_longR1:
name: Left Hold Button State 1
description: Action to run when Long press
default: []
selector:
action: {}
onR2:
name: On Button State 2
description: Action to run when SHORT press
default: []
selector:
action: {}
offR2:
name: Off Button State 2
description: Action to run when SHORT press
default: []
selector:
action: {}
on_longR2:
name: Brightness up Button State 2
description: Action to run when Long press
default: []
selector:
action: {}
off_longR2:
name: Brightness down Button State 2
description: Action to run when Long press
default: []
selector:
action: {}
right_longR2:
name: Right Hold Button State 2
description: Action to run when Long press
default: []
selector:
action: {}
left_longR2:
name: Left Hold Button State 2
description: Action to run when Long press
default: []
selector:
action: {}
onR3:
name: On Button State 3
description: Action to run when SHORT press
default: []
selector:
action: {}
offR3:
name: Off Button State 3
description: Action to run when SHORT press
default: []
selector:
action: {}
on_longR3:
name: Brightness up Button State 3
description: Action to run when Long press
default: []
selector:
action: {}
off_longR3:
name: Brightness down Button State 3
description: Action to run when Long press
default: []
selector:
action: {}
right_longR3:
name: Right Hold Button State 3
description: Action to run when Long press
default: []
selector:
action: {}
left_longR3:
name: Left Hold Button State 3
description: Action to run when Long press
default: []
selector:
action: {}
onR4:
name: On Button State 4
description: Action to run when SHORT press
default: []
selector:
action: {}
offR4:
name: Off Button State 4
description: Action to run when SHORT press
default: []
selector:
action: {}
on_longR4:
name: Brightness up Button State 4
description: Action to run when Long press
default: []
selector:
action: {}
off_longR4:
name: Brightness down Button State 4
description: Action to run when Long press
default: []
selector:
action: {}
right_longR4:
name: Right Hold Button State 4
description: Action to run when Long press
default: []
selector:
action: {}
left_longR4:
name: Left Hold Button State 4
description: Action to run when Long press
default: []
selector:
action: {}
mode: restart
max_exceeded: silent
variables:
helper_selector: !input helper_selector
trigger:
- platform: state
entity_id:
- !input remote
to: "on"
id: "on"
- platform: state
entity_id:
- !input remote
to: "off"
id: "off"
- platform: state
entity_id:
- !input remote
to: "arrow_right_click"
id: "right"
- platform: state
entity_id:
- !input remote
to: "arrow_left_click"
id: "left"
- platform: state
entity_id:
- !input remote
to: "brightness_move_up"
id: "on_long"
- platform: state
entity_id:
- !input remote
to: "brightness_move_down"
id: "off_long"
- platform: state
entity_id:
- !input remote
to: "arrow_right_hold"
id: "right_long"
- platform: state
entity_id:
- !input remote
to: "arrow_left_hold"
id: "left_long"
- platform: state
entity_id:
- !input remote
to: "arrow_right_release"
id: "right_stop"
- platform: state
entity_id:
- !input remote
to: "arrow_left_release"
id: "left_stop"
- platform: state
entity_id:
- !input remote
to: "brightness_stop"
id: "stop"
action:
- choose:
- conditions:
- condition: trigger
id: "on"
sequence:
- choose:
- conditions:
- condition: state
entity_id: !input helper_selector
state: State01
sequence: !input onR1
- conditions:
- condition: state
entity_id: !input helper_selector
state: State02
sequence: !input onR2
- conditions:
- condition: state
entity_id: !input helper_selector
state: State03
sequence: !input onR3
- conditions:
- condition: state
entity_id: !input helper_selector
state: State04
sequence: !input onR4
- conditions:
- condition: trigger
id: "off"
sequence:
- choose:
- conditions:
- condition: state
entity_id: !input helper_selector
state: State01
sequence: !input offR1
- conditions:
- condition: state
entity_id: !input helper_selector
state: State02
sequence: !input offR2
- conditions:
- condition: state
entity_id: !input helper_selector
state: State03
sequence: !input offR3
- conditions:
- condition: state
entity_id: !input helper_selector
state: State04
sequence: !input offR4
- conditions:
- condition: trigger
id: "on_long"
sequence:
- choose:
- conditions:
- condition: state
entity_id: !input helper_selector
state: State01
sequence: !input on_longR1
- conditions:
- condition: state
entity_id: !input helper_selector
state: State02
sequence: !input on_longR2
- conditions:
- condition: state
entity_id: !input helper_selector
state: State03
sequence: !input on_longR3
- conditions:
- condition: state
entity_id: !input helper_selector
state: State04
sequence: !input on_longR4
- conditions:
- condition: trigger
id: "off_long"
sequence:
- choose:
- conditions:
- condition: state
entity_id: !input helper_selector
state: State01
sequence: !input off_longR1
- conditions:
- condition: state
entity_id: !input helper_selector
state: State02
sequence: !input off_longR2
- conditions:
- condition: state
entity_id: !input helper_selector
state: State03
sequence: !input off_longR3
- conditions:
- condition: state
entity_id: !input helper_selector
state: State04
sequence: !input off_longR4
- conditions:
- condition: trigger
id: "right"
sequence:
- if:
- condition: state
entity_id: !input helper_selector
state: unknown
then:
- service: input_select.select_first
data: {}
target:
entity_id: !input helper_selector
else:
- service: input_select.select_next
data: {}
target:
entity_id: !input helper_selector
- conditions:
- condition: trigger
id: "left"
sequence:
- if:
- condition: state
entity_id: !input helper_selector
state: unknown
then:
- service: input_select.select_last
data: {}
target:
entity_id: !input helper_selector
else:
- service: input_select.select_previous
data: {}
target:
entity_id: !input helper_selector
- conditions:
- condition: trigger
id: "right_long"
sequence:
- choose:
- conditions:
- condition: state
entity_id: !input helper_selector
state: State01
sequence: !input right_longR1
- conditions:
- condition: state
entity_id: !input helper_selector
state: State02
sequence: !input right_longR2
- conditions:
- condition: state
entity_id: !input helper_selector
state: State03
sequence: !input right_longR3
- conditions:
- condition: state
entity_id: !input helper_selector
state: State04
sequence: !input right_longR4
- conditions:
- condition: trigger
id: "left_long"
sequence:
- choose:
- conditions:
- condition: state
entity_id: !input helper_selector
state: State01
sequence: !input left_longR1
- conditions:
- condition: state
entity_id: !input helper_selector
state: State02
sequence: !input left_longR2
- conditions:
- condition: state
entity_id: !input helper_selector
state: State03
sequence: !input left_longR3
- conditions:
- condition: state
entity_id: !input helper_selector
state: State04
sequence: !input left_longR4