ZHA - IKEA five button remote for lights

Tags: #<Tag:0x00007f32745a5a48> #<Tag:0x00007f32745a5958>

This is a blueprint for the IKEA five-button remotes (the round ones), specifically for use with ZHA.

It was specially created for use with (any) light(s). As the basic light controls are already mapped in this blueprint.

The middle “on” button, toggle the lights on/off to the last set brightness (unless the force brightness is toggled on in the blueprint). Dim 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.

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: ZHA - IKEA five button remote for lights
  description: |
    Control lights with an IKEA five button remote (the round ones).

    The middle "on" button, toggle the lights on/off to the last set brightness
    (unless the force brightness is toggled on in the blueprint).

    Dim 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.

  domain: automation
  input:
    remote:
      name: Remote
      description: IKEA remote to use
      selector:
        device:
          integration: zha
          manufacturer: IKEA of Sweden
          model: TRADFRI remote control
    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: 50
      selector:
        number:
          min: 0
          max: 100
          mode: slider
          step: 1
          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
      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
      default: []
      selector:
        action:

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 == 'toggle' }}"
          - "{{ cluster_id == 6 }}"
          - "{{ endpoint_id == 1 }}"
        sequence:
          - choose:
              - conditions: "{{ force_brightness }}"
                sequence:
                  - service: light.toggle
                    target: !input light
                    data:
                      transition: 1
                      brightness_pct: !input brightness
            default:
              - service: light.toggle
                target: !input light
                data:
                  transition: 1

      - conditions:
          - "{{ command == 'step_with_on_off' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
          - "{{ args == [0, 43, 5] }}"
        sequence:
          - service: light.turn_on
            target: !input light
            data:
              brightness_step_pct: 10
              transition: 1

      - conditions:
          - "{{ command == 'move_with_on_off' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
          - "{{ args == [0, 84] }}"
        sequence:
          - repeat:
              count: 10
              sequence:
                - service: light.turn_on
                  target: !input light
                  data:
                    brightness_step_pct: 10
                    transition: 1
                - delay: 1

      - conditions:
          - "{{ command == 'step' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
          - "{{ args == [1, 43, 5] }}"
        sequence:
          - service: light.turn_on
            target: !input light
            data:
              brightness_step_pct: -10
              transition: 1

      - conditions:
          - "{{ command == 'move' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
          - "{{ args == [1, 84] }}"
        sequence:
          - repeat:
              count: 10
              sequence:
                - service: light.turn_on
                  target: !input light
                  data:
                    brightness_step_pct: -10
                    transition: 1
                - delay: 1

      - 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
18 Likes

Interesting. I’m sure people will come up some super creative ways to use this feature. :+1:

Is this really smooth dimming? I only see light.turn_on with brigtness_step_pct, in my experience this is far away from “smooth” dimming.

Yes, it is eased out with a transition, and combined with the restart of the automation, it will give a smooth effect.

I should add a small video clip maybe :thinking:

1 Like

Yes, please. I never got a satisfying experience with the light.turn_on service.

1 Like

Using that remote also, but with a different take on left/right. I have 5 lights in a room and use left button to step through them in a sequence, then I use brightness up/down for on/off. The toggle button is used to reset the sequence.

I considered using right button to step through a sequence for window covers but didn’t implement. Remembering last arrow would allow a different function for up/down: light or cover.

It sounds like a lot of button presses to switch on light no. 2: toggle, left, left, brightness up, but then one remote for 5 lights is pretty ok. Switching on light 3 is then left, up. So if you operate 2 or 3 then it is fairly ok.

There is ZHA in the title. So it will not work with zigbee2mqtt, right? (I wonder why though)

It doesn’t work with z2m because z2m exposes devices to HASS in a different way. Specifically, events are states on entities instead of events of zha_event type.

Great work! Easy setup for lots of buttons

I’m excited to try this out! I use Z2M though so perhaps I’ll figure out how to pick a different device and fork @frenck’s blueprint.

Z2M uses actual entities instead of events, so you’d just need to swap out the trigger for states you’re expecting, and change the declaration of what ‘remote’ is expecting I think.

just realised - only ZHA :frowning: would love to see the same blueprint for Z2M

Thanks Franck… now you made me go and buy 4 of these remotes… :man_facepalming:

1 Like

This is great! Actually, I did create an AppDaemon app for this specific purpose. It allows you to integrate your remotes with:

  • Z2M (state)
  • Z2M (MQTT)
  • deCONZ
  • ZHA

You can get this functionality starting with less than 10 lins of YAML config, and going higher if specific cases are needed.

It also allows you to virtually manage multiple clicks for controllers like this one that do not supported them natively.

You can go and check it out in here:

However, if the HA team keeps this path and catches up with everything than ControllerX does, I might drop the project since initial setup is much easier and faster, as well as having a UI configuration.

Really good job, looking forward to using bluprints from now on.

Cheers,
Xavi M.

4 Likes

great!
is there a way to have the same for the 2 buttons ikea trader remote?

Strange, I am getting “No Matching Device Found”?

Any ideas or pointers?

Screenshot 2020-12-14 at 09.55.16

Not strange, as the topic says this is for ZHA integration not IKEA TRÅDFRI.

And if this did not make it clear this should have;

Working with ZHA with and an IKEA TRADFRI bulb E27 WS opal 1000lm.
It is working with brightness short press only. If I do long press nothing happens.
I also can not change color with the left or right buttons. Only options you can chose are; turn on, turn off, toggle, increase brightness, decrease brightness or flash. How can I make this change color as well?

1 Like

ZHA is a specific module? Guess I just learned! Thanks

Alright I think my fork for Zigbee2Mqtt is working. Here’s the gist! Just paste the url into Blueprints

In my example, my IKEA Remote is called Office Remote so Z2M calls the sensor I’m aiming for sensor.office_remote_action.