ZHA - IKEA TRADFRI - 5 Button Remote - Custom Actions

Mine still work, did you try re-pairing the device?

p.s. the quirk on my device is the same as yours
zhaquirks.ikea.fivebtnremotezha.IkeaTradfriRemote1

think the new zha update fixed it. cheers

Hey niro1987
I am interested to hear if you have solution for the IKEA N2 control? (as Mikael refers to).
thanks in advance

Partially: check out my GitHub, look for the STYRBAR files.

The problem is that the remote sends out the ‘on’ command together with the ‘hold’ command whenever you hold down on one of the arrow buttons. That makes the Custom Actions version of the script difficult.

Ho can you add a condition to one of the button’s actions, basically only turn a light on if a condition is satisfied. This templated doesn’t seem to allow this as all conditions specified are on a parallel level and not cascaded.

What you want, you can do in a script and then use one of the actions from this blueprint to fire the script.

1 Like

I paired a new 5 button remote to HA, and I noticed that the Color Up and Color Down buttons don’t do anything in an automation created with this blueprint. I checked an older 5 button remote I already had paired, and they don’t do anything with that one either. I don’t know whether they were working before and when they may have stopped working.

I listened to zha_event when the buttons are pressed, and the events seem fine and are recognized each time. I’m seeing this in the logs for Color Up, for example:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "[deleted]",
        "unique_id": "[deleted]",
        "device_id": "[deleted]",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "press",
        "args": [
            256,
            13,
            0
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2022-05-24T00:49:11.732187+00:00",
    "context": {
        "id": "[deleted]",
        "parent_id": null,
        "user_id": null
    }
}

But the action in the automation isn’t performed. What else can I check or do to figure out why it’s not working?

Try removing the device from the network an pair it again.

Hey thanks for all your blueprints! Can I somehow cycle through the light temperature?

Have a look at this blueprint

1 Like

Right, found that one! Thanks again for these blueprints!!

hey there, awesome blueprints. thanks so much for taking the time to make these. i’ve got a quick question: how should i go about setting up a light group to change (or toggle through?) color temperatures using the Short Press - Color Up/Down Button? I specifically would like to be able to do this using the Custom Actions blueprint, because I’d like to be able to have the flexibility to be able to utilize short-press and long-press actions. Thank you!

Have a look at the code in this blueprint to understand more about the inner workings.

done, thank you. you’ve done really good work here.

for everybody else that may be wondering how to combine the Custom Actions blueprint with something like the Warm Lights blueprint, try out the code here:

---
# This automation simulates the use of the IKEA TRADFRI Remote control
# connected through ZHA.

# | Button   | Action               |
# | -------- | -------------------- |
# | Power    | Toggle the light     |
# | Dim-Up   | Increase brightness  |
# | Dim-Down | Decrease brightness  |
# | Right    | Custom Action        |
# | Left     | Custom Action        |

blueprint:
  name: ZHA - IKEA TRADFRI - 5 Button Remote - Warm White Lights + Custom Right/Left Presets
  # merged these two:
  # https://community.home-assistant.io/t/zha-ikea-tradfri-5-button-remote-warm-white-lights/284738
  # https://community.home-assistant.io/t/zha-ikea-tradfri-5-button-remote-custom-actions/284720

  description: >-
    This automation simulates the use of the IKEA TRADFRI remote control
    connected through ZHA.

  domain: automation

  input:
    remote:
      name: IKEA TRADFRI remote control
      description: Select the remote control you wish to use.
      selector:
        device:
          integration: zha
          manufacturer: IKEA of Sweden
          model: TRADFRI remote control
    light:
      name: Light
      description: Select the light entity you wish to control.
      selector:
        entity:
          domain: light
    speed:
      name: Speed
      description: The speed in which to update the light when the button is held.
      selector:
        number:
          min: 100
          max: 1000
          step: 100
          unit_of_measurement: milliseconds
          mode: slider
      default: 500

    colorup_short:
      name: Short Press - Color Up Button
      description: The action to perform on Short Press of the Color Up Button
      selector:
        action:
      default: []
    colordown_short:
      name: Short Press - Color Down Button
      description: The action to perform on Short Press of the Color Down Button
      selector:
        action:
      default: []
    colorup_long:
      name: Long Press - Color Up Button
      description: The action to perform on Long Press of the Color Up Button
      selector:
        action:
      default: []
    colordown_long:
      name: Long Press - Color Down Button
      description: The action to perform on Long Press of the Color Down Button
      selector:
        action:
      default: []

mode: restart
max_exceeded: silent

variables:
  var_light: !input light
  var_speed: !input speed

trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input remote

action:
  - choose:
      # Short-Press on the power button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "toggle" }}'
        sequence:
          - service: light.toggle
            target:
              entity_id: !input light

      # Long-Press on the power button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "move_to_level_with_on_off" }}'
        sequence:
          - service: light.turn_on
            target:
              entity_id: !input light
            data:
              brightness: 254
              color_temp: 400

      # Short-Press on the dim-up button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "step_with_on_off" }}'
        sequence:
          - service: light.turn_on
            target:
              entity_id: !input light
            data:
              brightness_step_pct: 20
              transition: "{{ (var_speed / 1000)|float }}"

      # Long-Press on the dim-up button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "move_with_on_off" }}'
        sequence:
          - repeat:
              while: []
              sequence:
                - service: light.turn_on
                  target:
                    entity_id: !input light
                  data:
                    brightness_step_pct: 10
                    transition: "{{ (var_speed / 1000)|float }}"
                - delay:
                    milliseconds: !input speed

      # Short-Press on the dim-down button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "step" }}'
        sequence:
          - service: light.turn_on
            target:
              entity_id: !input light
            data:
              brightness_step_pct: -20
              transition: "{{ (var_speed / 1000)|float }}"

      # Long-Press on the dim-down button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "move" }}'
        sequence:
          - repeat:
              while: []
              sequence:
                - service: light.turn_on
                  target:
                    entity_id: !input light
                  data:
                    brightness_step_pct: -10
                    transition: "{{ (var_speed / 1000)|float }}"
                - delay:
                    milliseconds: !input speed

      # Short-Press on the color-up button.
      # - conditions:
      #     - condition: template
      #       value_template: '{{ trigger.event.data.command == "press" }}'
      #     - condition: template
      #       value_template: "{{ trigger.event.data.args == [256,13,0] }}"
      #   sequence:
      #     - service: light.turn_on
      #       target:
      #         entity_id: !input light
      #       data:
      #         color_temp: >-
      #           {% if state_attr(var_light, "color_temp") - 18 < 153 %}
      #             {{ 153 }}
      #           {% else %}
      #             {{ state_attr(var_light, "color_temp") - 18 }}
      #           {% endif %}
      #         transition: "{{ (var_speed / 1000)|float }}"

      # Short-Press on the color-up button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "press" }}'
          - condition: template
            value_template: "{{ trigger.event.data.args == [256,13,0] }}"
        sequence: !input colorup_short

      # Long-Press on the color-up button.
      # - conditions:
      #     - condition: template
      #       value_template: '{{ trigger.event.data.command == "hold" }}'
      #     - condition: template
      #       value_template: "{{ trigger.event.data.args == [3328,0] }}"
      #   sequence:
      #     - repeat:
      #         while: []
      #         sequence:
      #           - service: light.turn_on
      #             target:
      #               entity_id: !input light
      #             data:
      #               color_temp: >-
      #                 {% if state_attr(var_light, "color_temp") - 18 < 153 %}
      #                   {{ 153 }}
      #                 {% else %}
      #                   {{ state_attr(var_light, "color_temp") - 18 }}
      #                 {% endif %}
      #               transition: "{{ (var_speed / 1000)|float }}"
      #           - delay:
      #               milliseconds: !input speed

      # Long-Press on the color-up button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "hold" }}'
          - condition: template
            value_template: "{{ trigger.event.data.args == [3328,0] }}"
        sequence: !input colorup_long

      # Short-Press on the color-down button.
      # - conditions:
      #     - condition: template
      #       value_template: '{{ trigger.event.data.command == "press" }}'
      #     - condition: template
      #       value_template: "{{ trigger.event.data.args == [257,13,0] }}"
      #   sequence:
      #     - service: light.turn_on
      #       target:
      #         entity_id: !input light
      #       data:
      #         color_temp: >-
      #           {% if state_attr(var_light, "color_temp") + 18 > 500 %}
      #             {{ 500 }}
      #           {% else %}
      #             {{ state_attr(var_light, "color_temp") + 18 }}
      #           {% endif %}
      #         transition: "{{ (var_speed / 1000)|float }}"

      # Short-Press on the color-down button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "press" }}'
          - condition: template
            value_template: "{{ trigger.event.data.args == [257,13,0] }}"
        sequence: !input colordown_short

      # Long-Press on the color-down button.
      # - conditions:
      #     - condition: template
      #       value_template: '{{ trigger.event.data.command == "hold" }}'
      #     - condition: template
      #       value_template: "{{ trigger.event.data.args == [3329,0] }}"
      #   sequence:
      #     - repeat:
      #         while: []
      #         sequence:
      #           - service: light.turn_on
      #             target:
      #               entity_id: !input light
      #             data:
      #               color_temp: >-
      #                 {% if state_attr(var_light, "color_temp") + 18 > 500 %}
      #                   {{ 500 }}
      #                 {% else %}
      #                   {{ state_attr(var_light, "color_temp") + 18 }}
      #                 {% endif %}
      #               transition: "{{ (var_speed / 1000)|float }}"
      #           - delay:
      #               milliseconds: !input speed

      # Long-Press on the color-down button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "hold" }}'
          - condition: template
            value_template: "{{ trigger.event.data.args == [3329,0] }}"
        sequence: !input colordown_long

    # Any other event will cancel the repeat loops.
    default: []

What this code does is basically give you the option to use the Left/Right arrow keys for custom actions AND the original Warm Lights (incl. smooth brightness controls)

the input fields look like this:

Thank you!

I’d tried other blueprints that were too complex for me to get working but this one just works! Thanks again.

1 Like


How can I see my IKEA remote like this?

In the ZHA integration page

Hello!

The up/down buttons seem to have stopped working for me. I see this in the log (but no light brightness increase/decrease)

TRADFRI 5 Button Remote Control B Step event was fired with parameters: {'step_mode': <StepMode.Down: 1>, 'step_size': 43, 'transition_time': 5, 'options_mask': <bitmap8: 0>, 'options_override': <bitmap8: 0>}

Any ideas?

I already tried removing and re-adding the device, but it did not help.

Thanks!

I’ll have a look.

Thanks, this works! I’m using it to control a pair of speakers. Dim Up/Down = Volume Up/Down. The step is too much though, is this choose-hack also applicable in my case?

(I wonder why you chose to call it color Up/Down… would be more logical with Right/Left?)