ZHA - IKEA four button remote (Styrbar) for lights and switches

This blueprint is extended version for controlling lights and switches with the IKEA four button remote (the square ones), integrated via ZHA.

It extends @Malte’s version (no switches) which is extending @SwerveShot’s version (incomplete and hasn’t seen any recent activity) which is based on the work of @frenck with the five button version.

Pressing the up button will turn on the lights at the last set brightness (unless the force brightness is toggled on in the blueprint) and turn on configured switches.

Pressing the down button will turn the lights and switches off again.

Pressing and holding the 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. Use the left and right button events with care, as before the long press event is sent, the “on” event gets triggered.

This is what the Blueprint looks like from the UI:

Blueprint Code

Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Or import this Blueprint by using the forum topic URL:

blueprint:
  name: IKEA four button remote for switches and lights
  description: 'Control lights and switches with an IKEA four button remote (the square ones),
    for use with [ZHA](https://www.home-assistant.io/integrations/zha/).

    Extends [Malte](https://community.home-assistant.io/u/Malte)''s [version](https://community.home-assistant.io/t/zha-ikea-four-button-remote-styrbar-for-lights-e2001-e2002/384482)
    which is based on [SwerveShot](https://community.home-assistant.io/u/SwerveShot)''s [version](https://community.home-assistant.io/t/zha-ikea-four-button-remote-for-lights/347657)
    which is based on the work of [frenck](https://community.home-assistant.io/u/frenck)
    with the five button version.

    Pressing the up button will turn on the lights at the last set brightness (unless
    the force brightness is toggled on in the blueprint) and turn on selected switches.

    Pressing the down button will turn the lights off again and turn off selected switches.

    Pressing and holding the 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. Use the left
    and right button events with care, as before the long press event is sent, the
    "on" event gets triggered.

    '
  domain: automation
  input:
    remote:
      name: Remote
      description: IKEA remote to use
      selector:
        device:
          integration: zha
          manufacturer: IKEA of Sweden
          model: Remote Control N2
    switch:
      name: Switch(es)
      description: The switch(es) to control
      selector:
        target:
            entity:
                domain: switch
    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: 100
      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. Use with care, as before
        the long press event is sent, the "on" event gets triggered.
      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. Use with care, as before
        the long press event is sent, the "on" event gets triggered.
      default: []
      selector:
        action: {}
  source_url: https://community.home-assistant.io/t/zha-ikea-four-button-remote-styrbar-for-lights-and-switches/395248
mode: restart
max_exceeded: silent
variables:
  force_brightness: !input 'force_brightness'
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 == ''on'' }}'
    - '{{ cluster_id == 6 }}'
    - '{{ endpoint_id == 1 }}'
    sequence:
    - choose:
      - conditions: '{{ force_brightness }}'
        sequence:
        - service: light.turn_on
          target: !input 'light'
          data:
            brightness_pct: !input 'brightness'
        - service: switch.turn_on
          target: !input 'switch'
      default:
      - service: light.turn_on
        target: !input 'light'
      - service: switch.turn_on
        target: !input 'switch'
  - conditions:
    - '{{ command == ''off'' }}'
    - '{{ cluster_id == 6 }}'
    - '{{ endpoint_id == 1 }}'
    sequence:
    - service: light.turn_off
      target: !input 'light'
    - service: switch.turn_off
      target: !input 'switch'
  - conditions:
    - '{{ command == ''move_with_on_off'' }}'
    - '{{ cluster_id == 8 }}'
    - '{{ endpoint_id == 1 }}'
    - '{{ args == [0, 83] }}'
    sequence:
    - repeat:
        count: 10
        sequence:
        - service: light.turn_on
          target: !input 'light'
          data:
            brightness_step_pct: 10
            transition: 1
        - delay: 0.5
  - conditions:
    - '{{ command == ''move'' }}'
    - '{{ cluster_id == 8 }}'
    - '{{ endpoint_id == 1 }}'
    - '{{ args == [1, 83] }}'
    sequence:
    - repeat:
        count: 10
        sequence:
        - service: light.turn_on
          target: !input 'light'
          data:
            brightness_step_pct: -10
            transition: 1
        - delay: 0.5
  - 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'

Hi there
I’m not sure this is normal but when I let the button “down” push the light does not turn off.
Or even with a double push, etc.
But if I select an action for the left or right button to power off the light it’s working well.
Not a big issue in my case as I only have one light but wondering if it was the normal behaviour :).

Sooo, i tried your blueprint.
And well at first it looks awesome, and its exactly what i need.
But I get the following error, when adding without a switch.

Message malformed: Missing input switch

And well, i dont have a seperate switch that i want to turn on or off.
I just use the remote to turn on my light.

Is there something i can change in the blueprint to fix this?

edit:
Nevermind, i edited your code and removed all the switch fields and lines. Got it working now like i wanted to thanks though :slight_smile:

Can you explain how you changed the code as I need to do the same?
Thanks

I changed the code like this - IKEA four button remote for lights W/O switches · GitHub (the URL can be imported as blueprint).
I can now set it up without a switch, but for me it only works as an On/Off switch… continuous holding does nothing :frowning: