Deprecated ZHA - IKEA Styrbar - Custom Actions

Deprecated. Use the blueprints from Awesome Home Assistant instead.

Check out @niro1987 's awesome blueprint for the Tradfri 5 Button remote, this blueprint is based on his work and adopted to work with the Styrbar remote. Thank @niro1987!

Button Action
Dim-Up (short) User defined action
Dim-Down (short) User defined action
Right (short) User defined action
Left (short) User defined action
Dim-Up (long) User defined action
Dim-Down (long) User defined action
Right (long) User defined action (may trigger “Dim-Up (short)” action, known issue)
Left (long) User defined action (may trigger “Dim-Up (short)” action, known issue)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:

  name: ZHA - IKEA Styrbar - Custom Actions

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

  domain: automation

  input:
    remote:
      name: IKEA Styrbar remote control
      description: Select the remote control you wish to use.
      selector:
        device:
          integration: zha
          manufacturer: IKEA of Sweden
          model: Remote Control N2
    dimup_short:
      name: Short Press - Dim Up Button
      description: The action to perform on Short Press of the Dim Up Button
      selector:
        action:
      default: []
    dimdown_short:
      name: Short Press - Dim Down Button
      description: The action to perform on Short Press of the Dim Down Button
      selector:
        action:
      default: []
    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: []
    dimup_long:
      name: Long Press - Dim Up Button
      description: The action to perform on Long Press of the Dim Up Button
      selector:
        action:
      default: []
    dimdown_long:
      name: Long Press - Dim Down Button
      description: The action to perform on Long Press of the Dim 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

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

action:
  - choose:
      # Short-Press on the dim-up button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "on" }}'
        sequence: !input dimup_short

      # Long-Press on the dim-up button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "move_with_on_off" }}'
        sequence: !input dimup_long

      # Short-Press on the dim-down button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "off" }}'
        sequence: !input dimdown_short

      # Long-Press on the dim-down button.
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.command == "move" }}'
        sequence: !input dimdown_long

      # 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: !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: !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: !input colordown_long

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

Thank you so much - worked like a charm

Thanks JeffKrz for your portation of niros blueprint to the Styrbar Remote.
Unfortunately I ran into an issue when toggeling some relais with the color up and color down buttons. I want both buttons to toggle one relais on when it was off and off when it was on.
When I press on of the color buttons (left or right arrow on the styrbar) i get a double trigger. So the relais will be ‘on’ for just a short period of time. Less then a second.
First I reset the styrbar and connected it to ZHA again. The problem was gone for an hour or so, but came back again.
I looked into trace and found one trigger on, two times cancelled and one trigger off. All with one press on the button for color up. I tried the same procedure with a five button tradfri remote. There was no problem at all.
As a workaround I put a delay within the automation for the color buttons. Can’t say why the styrbar remotes are acting this strange. Maybe it needs some further quirks in the ZHA component.

Turns my lights epileptic, needs some debouncing

Thanks you all for your Feedback.

@ornago I can reproduce the issue you are describing. When long-pressing the arrow buttons, multiple events are triggered. besides the expected “hold” and “release” commands, there are also events with the command “on”, which is triggering the wrong action. So there is indeed an issue in the behavior of ZHA or the remote itself.

I can also reproduce this behaviour, anyone know a fix?

Maybe a debouncer could solve the issue?
This blueprint for the “shortcut” seems to work in this scenario: ZHA - IKEA Tradfri Shortcut button debounced

I also have the issue where the left & right buttons are triggering the “on” command when doing a long press. Is there no fix for this?

1 Like

Have you got any solution on this? I am having the same issue.

I have a solution for it, but it’s in Node red

Would you mind sharing what you did in NodeRed? maybe I can adopt it to the blueprint

This is the automations I have to one of the remotes, it is to control a RGB Shelly bulb for my sons room:

(it was too large to post here)

The part that does makes sure there is no “on” registered is this part here:

Where the red part makes sure the green does not let a message through.

1 Like

Hello,

Thanks for the blueprint. I tried using it to turn on/off my relays by setting up the action to call service - ‘switch.turn_on’ on the desired entity, but it doesn’t work even when I trigger the automation in home assistant. Does anyone has any idea on what could I be doing wrong?