This is based on https://community.home-assistant.io/t/zigbee2mqtt-ikea-five-button-remote/255308/8
it’s the code to control your lights with the on/off switch, it has 2 function.
short press and long press.
blueprint:
name: zigbee2mqtt - Tradfri on/of button
description: 'Control on off switch from IKEA Tradfri.
The button has 2 functions
- short press
- long press
This blue print is
Inspired by the blueprint of @starbuck93 (https://community.home-assistant.io/t/zigbee2mqtt-ikea-five-button-remote/255308)
Choce only sensor type action.
'
domain: automation
input:
switch:
name: switch
description: Tradfri on/off switch
selector:
entity:
domain: sensor
light_1:
name: Short press action
description: The light(s) to control
selector:
target:
entity:
domain: light
light_2:
name: Long press action
description: The light(s) to control
selector:
target:
entity:
domain: light
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input 'switch'
attribute: action
action:
- variables:
command: '{{ trigger.to_state.state }}'
- choose:
- conditions:
- '{{ command == ''off'' }}'
sequence:
- service: light.turn_off
target: !input 'light_1'
data: {}
- conditions:
- '{{ command == ''on'' }}'
sequence:
- service: light.turn_on
data: {}
target: !input 'light_1'
- conditions:
- '{{ command == ''brightness_move_down'' }}'
sequence:
- service: light.turn_off
data: {}
target: !input 'light_2'
- conditions:
- '{{ command == ''brightness_move_up'' }}'
sequence:
- service: light.turn_on
data: {}
target: !input 'light_2'