ZHA - IKEA five button remote

You can see if the buttons are sending the expected commands. Go to developer tools, Events, and in “Event to subscribe to” type “zha_event” then click “Start listening”

Press the buttons and look at the packets to see what your buttons send.
Note that one press may send multiple commands

Event x fired x:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "x",
        "unique_id": "x",
        "device_id": "x",
        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "move_with_on_off",
        "args": [
            0,
            84
        ]
    },
... 

Check the endpoint and cluster, command and args.
Long up should be

        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "move_with_on_off",
        "args": [
            0,
            84
        ]

Long down should be

        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "move",
        "args": [
            1,
            84
        ]

(Note there may be multiple commands sent but check if one of them is the above)

If you see no messages at all then the buttons aren’t sending commands, perhaps they are bound to a light directly in which case you can try resetting the remote and re-adding to ZHA.

If you get actions but it sends a different cluster, command or args, you can change the blueprint to match what your remote sends.

Yeah interesting, I’ve got this instead for long up

        "cluster_id": 8,
        "command": "move_with_on_off",
        "args": [
            0,
            83
        ]
    },

And this for long down:

        "cluster_id": 8,
        "command": "move",
        "args": [
            1,
            83
        ]
    },

So seems like the “args” being 83 instead of 84 is enough to stop it working?

That would definitely be the cause, as that is how the trigger determines the appropriate button is pressed.

The blueprint can be changed so that either type of remote should work.
You can add this at the end of the blueprint file: (after sequence: !input button_right_long)

      - conditions:
          - "{{ command == 'move_with_on_off' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
          - "{{ args == [0, 83] }}"
        sequence: !input button_brightness_up_long

      - conditions:
          - "{{ command == 'move' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
          - "{{ args == [1, 83] }}"
        sequence: !input button_brightness_down_long
1 Like

Thanks all, that worked. Out of interest is there a way of reloading blueprints without a restart? Rebooting was the way I managed to get the changes to start working.

Incidentally, the Tradfri two button remote (square with 1/0 buttons) also uses move_with_on_off [0,83] for long up, and move [1,83] for long down, but the rest of the commands are different because it only has two buttons rather than five buttons.

You use “Reload Automations” under “Configuration/Server Controls” which also reloads blueprints.

1 Like

Original blueprint in first post is now edited to reflect 1, 83 as well

Credit to this post - Set a random color on a light

If you want “Left Button Short Press” and “Right Button Short Press” to mimic the default behaviour when paired with the IKEA Tradfri hub you can do the following:

Left Button Short Press

service: light.turn_on
data_template:
  hs_color:
    - >-
      {{ ((state_attr('light.living_room_lamp', 'hs_color')[0] or 0) - 30) % 360
      }}
    - 100
  transition: 1
entity_id: light.living_room_lamp

Right Button Short Press

service: light.turn_on
data_template:
  hs_color:
    - >-
      {{ (30 + (state_attr('light.living_room_lamp', 'hs_color')[0] or 0)) % 360
      }}
    - 100
  transition: 1
entity_id: light.living_room_lamp

Not optimal as the state_attr in the template refers to the entity_id, which takes away from the spirit of Blueprints, but it gets the job done :slight_smile:

Hi, trying to use this to control my sonos in the kitchen in the same way you are. mind posting the full automation? cant figure out the next/prev station + tts announcement of selected station :frowning:

Here is the full automation. You need to create an input-select “helper” which has the name of the sonos favorites listed. Small / large letters DO matter :slight_smile:

alias: Bad Ikea Remote
description: ''
use_blueprint:
  path: wormie/zha_ikea_remote.yaml
  input:
    remote: 8344d6257cec8adb32fc9d60e4025ae0
    button_on_off:
      - service: media_player.media_play_pause
        data:
          entity_id: media_player.bad_oppe_sonos
    button_brightness_up_short:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.bad_oppe_sonos', 'volume_level') | float
            + 0.1 }}
        entity_id: media_player.bad_oppe_sonos
        service: media_player.volume_set
    button_brightness_up_long:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.bad_oppe_sonos', 'volume_level') | float
            + 0.1 }}
        entity_id: media_player.bad_oppe_sonos
        service: media_player.volume_set
    button_brightness_down_short:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.bad_oppe_sonos', 'volume_level') | float
            - 0.1 }}
        entity_id: media_player.bad_oppe_sonos
        service: media_player.volume_set
    button_brightness_down_long:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.bad_oppe_sonos', 'volume_level') | float
            - 0.1 }}
        entity_id: media_player.bad_oppe_sonos
        service: media_player.volume_set
    button_left_short:
      - service: input_select.select_previous
        data: {}
        entity_id: input_select.bad_radio_stationer
      - data_template:
          message: |
            {{ states('input_select.bad_radio_stationer') }}
        entity_id: media_player.bad_oppe_sonos
        service: tts.google_translate_say
      - delay: '00:00:01.5'
      - data_template:
          source: |
            {{ states('input_select.bad_radio_stationer') }}
        entity_id: media_player.bad_oppe_sonos
        service: media_player.select_source
    button_right_short:
      - service: input_select.select_next
        data: {}
        entity_id: input_select.bad_radio_stationer
      - data_template:
          message: |
            {{ states('input_select.bad_radio_stationer') }}
        entity_id: media_player.bad_oppe_sonos
        service: tts.google_translate_say
      - delay: '00:00:01.5'
      - data_template:
          source: |
            {{ states('input_select.bad_radio_stationer') }}
        entity_id: media_player.bad_oppe_sonos
        service: media_player.select_source

I created an input_select.sonos_stations helper using the dropdown type with a few of my Sonos stations in the dropdown fields. I can’t get the left and right buttons to trigger it. The middle button and volume buttons are working. I think it is an issue with the input_select helper. Any ideas?

Here is the automation:

alias: ZHA - IKEA Sonos Office Remote
description: ''
use_blueprint:
  path: wormie_dk/zha-ikea-five-button-remote.yaml
  input:
    remote: d277813da1caa636ac5e00b190482ed5
    button_on_off:
      - service: media_player.media_play_pause
        data:
          entity_id: media_player.sonos_office_amp
    button_brightness_up_short:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.sonos_office_amp', 'volume_level') |
            float + 0.1 }}
        entity_id: media_player.sonos_office_amp
        service: media_player.volume_set
    button_brightness_up_long:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.sonos_office_amp', 'volume_level') |
            float + 0.1 }}
        entity_id: media_player.sonos_office_amp
        service: media_player.volume_set
    button_brightness_down_short:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.sonos_office_amp', 'volume_level') |
            float - 0.1 }}
        entity_id: media_player.sonos_office_amp
        service: media_player.volume_set
    button_brightness_down_long:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.sonos_office_amp', 'volume_level') |
            float - 0.1 }}
        entity_id: media_player.sonos_office_amp
        service: media_player.volume_set
    button_left_short:
      - service: input_select.select_previous
        data: {}
        entity_id: input_select.sonos_stations
      - data_template:
          message: |
            {{ states('input_select.sonos_stations') }}
        entity_id: media_player.sonos_office_amp
        service: tts.google_translate_say
      - delay: '00:00:01.5'
      - data_template:
          source: |
            {{ states('input_select.sonos_stations') }}
        entity_id: media_player.sonos_office_amp
        service: media_player.select_source
    button_right_short:
      - service: input_select.select_next
        data: {}
        entity_id: input_select.sonos_stations
      - data_template:
          message: |
            {{ states('input_select.sonos_stations') }}
        entity_id: media_player.sonos_office_amp
        service: tts.google_translate_say
      - delay: '00:00:01.5'
      - data_template:
          source: |
            {{ states('input_select.sonos_stations') }}
        entity_id: media_player.sonos_office_amp
        service: media_player.select_source

This is awesome! I loved my IKEA remotes more after this blueprint.
I think that the middle (on/off) button also has a long_press event. Any idea how I could include that one in the blueprint too?

I got it all working. My google translate service had a different name. I changed it to use the short press for next/previous track and the long press to change the stations.

alias: ZHA - IKEA Sonos Office Remote
description: ''
use_blueprint:
  path: wormie_dk/zha-ikea-five-button-remote.yaml
  input:
    remote: d277813da1caa636ac5e00b190482ed5
    button_on_off:
      - service: media_player.media_play_pause
        data:
          entity_id: media_player.sonos_office_amp
    button_brightness_up_short:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.sonos_office_amp', 'volume_level') |
            float + 0.1 }}
        entity_id: media_player.sonos_office_amp
        service: media_player.volume_set
    button_brightness_up_long:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.sonos_office_amp', 'volume_level') |
            float + 0.1 }}
        entity_id: media_player.sonos_office_amp
        service: media_player.volume_set
    button_brightness_down_short:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.sonos_office_amp', 'volume_level') |
            float - 0.1 }}
        entity_id: media_player.sonos_office_amp
        service: media_player.volume_set
    button_brightness_down_long:
      - data_template:
          volume_level: >
            {{ state_attr('media_player.sonos_office_amp', 'volume_level') |
            float - 0.1 }}
        entity_id: media_player.sonos_office_amp
        service: media_player.volume_set
    button_left_long:
      - service: input_select.select_previous
        data: {}
        entity_id: input_select.sonos_stations
      - data_template:
          message: |
            {{ states('input_select.sonos_stations') }}
        entity_id: media_player.sonos_office_amp
        service: tts.google_say
      - delay: '00:00:01.5'
      - service: media_player.select_source
        data_template:
          source: |
            {{ states('input_select.sonos_stations') }}
        entity_id: media_player.sonos_office_amp
    button_right_long:
      - service: input_select.select_next
        data: {}
        entity_id: input_select.sonos_stations
      - data_template:
          message: |
            {{ states('input_select.sonos_stations') }}
        entity_id: media_player.sonos_office_amp
        service: tts.google_say
      - delay: '00:00:01.5'
      - service: media_player.select_source
        data_template:
          source: |
            {{ states('input_select.sonos_stations') }}
        entity_id: media_player.sonos_office_amp
    button_right_short:
      - service: media_player.media_next_track
        data: {}
        entity_id: media_player.sonos_office_amp
    button_left_short:
      - service: media_player.media_previous_track
        data: {}
        entity_id: media_player.sonos_office_amp

First off, I love this Blueprint! Exactly what I was looking for!

Now, I actually AM using it with a light, specifically an LED RGB strip. I use On/Off for (duh) On/Off. Brightness is Brightness and Left/Right cycles through preset colors.

The problem I’m having is this: Cycling to a preset color requires calling the light.turn_on service. So, even if the light is off, if I hit Left or Right, the light comes on and moves to the next color. Is there a way to make it so Bright/Dim and Left/Right doing nothing if the light is off?

Thanks.

You can add a condition before the action such as
image

I updated to 2022.4.0 today and now this blueprint isn’t working. The “choose” chooses the default action, even though all conditions are met.

I uploaded a debug trace here: trace automation.controll_music_with_ikea_five_button_remote 2022-04-06T19 08 47.442008+00 00.json · GitHub

I ran into the same issue. This seems to work just fine without extra conditions:

blueprint:
  name: ZHA - IKEA five button remote
  description: |
    Control anything using IKEA five button remote

  domain: automation
  input:
    remote:
      name: Remote
      description: IKEA remote to use
      selector:
        device:
          integration: zha
          manufacturer: IKEA of Sweden
          model: TRADFRI remote control
    button_on_off:
      name: On off button press
      description: Action to run on press of on off button
      default: []
      selector:
        action:
    button_brightness_up_short:
      name: Brightness up button - short press
      description: Action to run on short brightness up press
      default: []
      selector:
        action:
    button_brightness_up_long:
      name: Brightness up button - long press
      description: Action to run on long brightness up press
      default: []
      selector:
        action:
    button_brightness_down_short:
      name: Brightness down button - short press
      description: Action to run on short brightness down press
      default: []
      selector:
        action:
    button_brightness_down_long:
      name: Brightness down button - long press
      description: Action to run on long brightness down press
      default: []
      selector:
        action:
    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

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' }}"
        sequence: !input button_on_off

      - conditions:
          - "{{ command == 'step_with_on_off' }}"
        sequence: !input button_brightness_up_short

      - conditions:
          - "{{ command == 'move_with_on_off' }}"
        sequence: !input button_brightness_up_long

      - conditions:
          - "{{ command == 'step' }}"
        sequence: !input button_brightness_down_short

      - conditions:
          - "{{ command == 'move' }}"
        sequence: !input button_brightness_down_long

      - conditions:
          - "{{ command == 'press' }}"
        sequence: !input button_left_short

      - conditions:
          - "{{ command == 'hold' }}"
        sequence: !input button_left_long

      - conditions:
          - "{{ command == 'press' }}"
        sequence: !input button_right_short

      - conditions:
          - "{{ command == 'hold' }}"
        sequence: !input button_right_long

5 Likes

Thanks. This managed to get another blueprint I use with IKEA on/off button long press working again.