Based on Zigbee2mqtt IKEA 5-button remote general use blueprint I adapted it to the STYRBAR 4 button remote:
blueprint:
name: Z2M - IKEA STYRBAR 4-button remote
description: "This blueprint is for the IKEA STYRBAR square, 4-button remote when used with zigbee2mqtt.
It is for general use so all buttons can be connected to any action of your choice"
domain: automation
input:
remote:
name: Remote
description: IKEA STYRBAR remote to use
selector:
entity:
integration: mqtt
domain: sensor
button_on:
name: Brightness up button - short press
description: Action to run when SHORT press on brighness UP button
default: []
selector:
action: {}
button_off:
name: Brightness down button - short press
description: Action to run when SHORT press on brighness DOWN button
default: []
selector:
action: {}
button_brightness_move_up:
name: Brightness up button - long press
description: Action to run when LONG press on brighness UP button
default: []
selector:
action: {}
button_brightness_move_down:
name: Brightness down button - long press
description: Action to run when LONG press on brighness DOWN button
default: []
selector:
action: {}
button_brightness_stop:
name: Brightness stop button - long release press
description: Action to run when LONG press on brighness (up or down) is released
default: []
selector:
action: {}
button_left_click:
name: Left button - short press
description: Action to run when SHORT press on LEFT arrow button
default: []
selector:
action: {}
button_left_hold:
name: Left button - hold
description: Action to run when HOLD press on LEFT arrow button
default: []
selector:
action: {}
button_left_release:
name: Left button - release
description: Action to run when RELEASE press on LEFT arrow button
default: []
selector:
action: {}
button_right_click:
name: Right button - short press
description: Action to run when SHORT press on RIGHT arrow button
default: []
selector:
action: {}
button_right_hold:
name: Right button - hold
description: Action to run when HOLD press on RIGHT button
default: []
selector:
action: {}
button_right_release:
name: Right button - release
description: Action to run when RELEASE press on RIGHT arrow button
default: []
selector:
action: {}
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input "remote"
attribute: action
action:
- variables:
command: "{{ trigger.to_state.state }}"
- choose:
- conditions:
- "{{ command == 'on' }}"
sequence: !input "button_on"
- conditions:
- "{{ command == 'off' }}"
sequence: !input "button_off"
- conditions:
- "{{ command == 'brightness_move_up' }}"
sequence: !input "button_brightness_move_up"
- conditions:
- "{{ command == 'brightness_move_down' }}"
sequence: !input "button_brightness_move_down"
- conditions:
- "{{ command == 'brightness_stop' }}"
sequence: !input "button_brightness_stop"
- conditions:
- "{{ command == 'arrow_left_click' }}"
sequence: !input "button_left_click"
- conditions:
- "{{ command == 'arrow_left_hold' }}"
sequence: !input "button_left_hold"
- conditions:
- "{{ command == 'arrow_left_release' }}"
sequence: !input "button_left_release"
- conditions:
- "{{ command == 'arrow_right_click' }}"
sequence: !input "button_right_click"
- conditions:
- "{{ command == 'arrow_right_hold' }}"
sequence: !input "button_right_hold"
- conditions:
- "{{ command == 'arrow_right_release' }}"
sequence: !input "button_right_release"