🎮 ZHA, deCONZ, Zigbee2MQTT - IKEA E2001/E2002 STYRBAR Remote control Universal blueprint - all actions + double click events - control lights, media players and more with Hooks

This blueprint is part of the Awesome HA Blueprints project.
Read more about it on the related Community Forum topic. :rocket:

Updates will be published on the project’s GitHub repository.

:arrow_down: Get Started

Option 1: My Home Assistant

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.

Option 2: Direct Link

Copy this link if you want to import the blueprint in your installation.

:link: Blueprint URL

:page_facing_up: Description

This blueprint provides universal support for running any custom action when a button is pressed on the provided IKEA E2001/E2002 STYRBAR Remote control. Supports controllers integrated with deCONZ, ZHA, Zigbee2MQTT. Just specify the integration used to connect the remote to Home Assistant when setting up the automation, and the blueprint will take care of all the rest.

In addition of being able to provide custom actions for every kind of button press supported by the remote, the blueprint allows to loop the long press actions while the corresponding button is being held. Once released, the loop stops. This is useful when holding down a button should result in a continuous action (such as lowering the volume of a media player, or controlling a light brightness).

The blueprint also adds support for virtual double button press events, which are not exposed by the controller itself.

Automations created with this blueprint can be connected with one or more Hooks supported by this controller.
Hooks allow to easily create controller-based automations for interacting with media players, lights, covers and more. See the list of Hooks available for this controller for additional details.

:closed_book: Full Documentation

Full documentation regarding requirements, inputs and more is available here.

Docs provide all the information you need to properly configure this blueprint on your instance.

:electric_plug: Available Hooks

:bulb: Light

This Hook blueprint allows to build a controller-based automation to control a light. Supports brightness and color control both for white temperature and rgb lights.

Light Hook docs

:loud_sound: Media Player

This Hook blueprint allows to build a controller-based automation to control a media player. Supports volume setting, play/pause and track selection.

Media Player Hook docs

:information_source: Changelog

Updated list of changes and improvements is available here.

Happy automating to everyone! :fire:

6 Likes

Hello. This blueprint looks exactly what I’d like to use. However I’m having some issues and I’m not sure if they are related to my deCONZ configuration or if I’m doing something wrong with the blueprints. So I’m trying to use controllers and hooks, but my E2001 controller is not connecting to my light hook. Here is my light hook configuration and controller configurations

So I only have the sensor.olohuone_kytkin_battery level entity for my button but I’m not sure if I should have something else? And because I want to use the default actions for the light hook I didn’t configure eany actions myself in the controller configuration. Are these right? And any ideas about what is the problem? My controller automation does trigger so that shouldn’t be the problem.

Thank you in advance :slight_smile:

Edit: It seems I wrongly assumed that the light hook needs to have the Zigbee gateway as the device. When I switched the controller device to the controller device everything works. Thank you for the blueprint, amazing work!

1 Like

Hi @JKalliomaki,

thank you for reporting here. I’m glad that you’ve managed to solve your issue.

So I only have the sensor.olohuone_kytkin_battery level entity for my button but I’m not sure if I should have something else?

You can safely remove the value you provided as the “Controller Entity” input in the Light Hook configuration: since you’re using deCONZ, this integration exposes the controller as a device to Home Assistant. Therefore, you should only provide a value for the “Controller Device” input, matching the device exposed by deCONZ for your controller.
Aside from this, configuration for both the controller and hook automations look great to me. :smiley:

If you’ve any additional questions or doubts feel free to ask, I’d be glad to help. Happy automating!

1 Like

Great blueprint

I was using it without any issue whilst using deconz to manage by zigbee network.

However yesterday I moved to ZHA and it seems that the blueprint has an issue picking double clicks.
As soon as I enable “expose double press event”, the blueprint will trigger the double click action whether I clicked single or double. Long clicks work OK.

EDIT: I resolved the issue

  • For some reason every single click was generating 4 click event (like if the device was paired multiple times).
  • Full reset + repaying resolved the issue (now only one event is fired and your blueprint functions like a charm)

jf

1 Like

Hi @jfparis,

thank you so much for your feedback. I’m glad that your issue is solved. :slight_smile:
I’ll add a small note on the blueprint documentation, stating that the controller might have this strange behavior with ZHA, and a full reset should solve the problem.

Happy automating!

1 Like

Hum, there’s an issue with the blueprint (zigbee2mqtt).

Whenever I long press the left or right button, the top button triggers a short press.

I have two different E2002 so it’s not a part issue.

2 Likes

Hi @Dumonster,

thank you for reporting here. Could you please share the YAML for the automation you set up with this blueprint?

Thanks!

I have the same problem on two distinct devices running the same blueprint so I’ll share both, in case it’s any help:

DEVICE ONE

- id: '1637588705936'
  alias: QuartoTiago_Dimmer
  description: ''
  use_blueprint:
    path: EPMatt/ikea_e2001_e2002.yaml
    input:
      integration: Zigbee2MQTT
      controller_entity: sensor.quartotiago_dimmer_action
      helper_last_controller_event: input_text.quartotiago_dimmer
      action_button_left_short:
      - service: media_player.media_previous_track
        target:
          entity_id: media_player.spotify_tiago_dumont
      action_button_left_long:
      - service: remote.send_command
        target:
          device_id: 2fffc1bb3694ca0c028f669130ffa6ba
        data:
          device: soundbar
          command: VOL-
      button_left_long_loop: true
      button_right_long_loop: true
      action_button_right_short:
      - service: media_player.media_next_track
        target:
          entity_id: media_player.spotify_tiago_dumont
      action_button_right_long:
      - service: remote.send_command
        target:
          device_id: 2fffc1bb3694ca0c028f669130ffa6ba
        data:
          device: soundbar
          command: VOL+
      action_button_up_short:
      - service: switch.turn_on
        target:
          entity_id: switch.quartotiago_luzcima
      action_button_up_long:
      - service: light.turn_on
        target:
          entity_id: light.quartotiago_luzescima
        data:
          brightness_step: 15
      - delay:
          hours: 0
          minutes: 0
          seconds: 0
          milliseconds: 250
      action_button_down_short:
      - service: switch.turn_off
        target:
          entity_id: switch.quartotiago_luzcima
      action_button_down_long:
      - service: light.turn_on
        data:
          brightness_step: -15
        target:
          entity_id: light.quartotiago_luzescima
      - delay:
          hours: 0
          minutes: 0
          seconds: 0
          milliseconds: 250
      button_up_long_loop: true
      button_down_long_loop: true

DEVICE TWO

- id: '1637590372702'
  alias: Sala_Dimmer
  description: ''
  use_blueprint:
    path: EPMatt/ikea_e2001_e2002.yaml
    input:
      integration: Zigbee2MQTT
      controller_entity: sensor.sala_dimmer_action
      helper_last_controller_event: input_text.sala_dimmer
      action_button_left_short:
      - service: switch.turn_on
        target:
          entity_id:
          - switch.salajantar_luzesfluorescentessala_left
          - switch.salajantar_luzesfluorescentessala_right
      action_button_left_long:
      - service: switch.turn_off
        target:
          entity_id:
          - switch.salajantar_luzesfluorescentessala_left
          - switch.salajantar_luzesfluorescentessala_right
      button_left_long_loop: true
      button_right_long_loop: true
      action_button_right_short:
      - service: switch.turn_on
        target:
          entity_id: switch.sala_luzcima_top
      action_button_right_long:
      - service: switch.turn_off
        target:
          entity_id: switch.sala_luzcima_top
      action_button_up_short:
      - service: switch.turn_on
        target:
          entity_id: switch.sala_luzcima_bottom
      action_button_up_long:
      - service: light.turn_on
        data:
          brightness_step: 15
        target:
          entity_id: light.sala_ltemp
      - delay:
          hours: 0
          minutes: 0
          seconds: 0
          milliseconds: 250
      action_button_down_short:
      - service: switch.turn_off
        target:
          entity_id: switch.sala_luzcima_bottom
      action_button_down_long:
      - service: light.turn_on
        data:
          brightness_step: -15
        target:
          entity_id: light.sala_ltemp
      - delay:
          hours: 0
          minutes: 0
          seconds: 0
          milliseconds: 250
      button_up_long_loop: true
      button_down_long_loop: true

Basically, on device one, when I hold one of the side buttons to increase\decrease the volume on my soundbar, the light will turn on.

On device two, when I hold one of the side buttons to turn off one of the auxiliary lights, the main light turns on.

Hum, if you expose the double press on any of the side buttons, the single press stops working.

Yeah I can’t really get more than one fuction from the side buttons with this template.

Either I have single click on but the holding makes the top button trigger, or I have the double click enabled and the single click stops working, or, or, or. Tried a bunch of things but it basically all comes around to the same.

I’m not code savy enough to troubleshoot this.

1 Like

Can this blueprint control a group of lights?
i.e. in configuration.yaml
[…]

 - platform: group
    name: "Livingroom"
    entities:
      - light.1
      - light.2
      - light.3
      - light.4
      - light.5

And if so, how do I select this group in “actions type”

It can. You call it just like any other light. In this case, it would show up and a light with name “Livingroom”.

So, no updates regarding the zigbee2mqtt integration being completely bugged for anything other than single clicks?

1 Like

@epmatt Thank you for putting together this blueprint, much appreciated :slight_smile:

I am however struggling to understand how to do the colour cycling?

I don’t see an option when configuring the left button short click:

Could you perhaps explain how to do this please?

Edit:

I downloaded the Hook - Light blueprint from Awesome HA Blueprints but I’m confused why I’d need this separate blueprint for the light colour control :thinking:

Edit 2:

I have to use 2 separate automations to get the desired functionality:

  • Up button short press → Turn on
  • Up button long press → Brightness up (continuous, until release)
  • Down button short press → Turn off
  • Down button long press → Brightness down (continuous, until release)
  • Left button short press → Color down
  • Left button long press → Color down (continuous, until release)
  • Right button short press → Color up
  • Right button long press → Color up (continuous, until release)

# Controller - IKEA E2001/E2002 STYRBAR Remote control Blueprint

alias: Bedroom Lamp
description: ''
use_blueprint:
  path: EPMatt/ikea_e2001_e2002.yaml
  input:
    integration: Zigbee2MQTT
    controller_device: <my_id>
    controller_entity: sensor.bedroom_lamp_main_button_action
    helper_last_controller_event: input_text.bedroom_lamp_button_last_event
    action_button_up_short:
      - type: turn_on
        device_id: <my_id>
        entity_id: light.bedroom_lamp
        domain: light
    action_button_down_short:
      - type: turn_off
        device_id: <my_id>
        entity_id: light.bedroom_lamp
        domain: light
    action_button_down_long:
      - device_id: <my_id>
        domain: light
        entity_id: light.bedroom_lamp
        type: brightness_decrease
    action_button_up_long:
      - device_id: <my_id>
        domain: light
        entity_id: light.bedroom_lamp
        type: brightness_increase
    button_down_long_loop: true
    button_up_long_loop: true
    action_button_left_short: []
    action_button_left_long: []

# Hook - Light Blueprint:

alias: Hook - Light
description: ''
use_blueprint:
  path: EPMatt/light.yaml
  input:
    light_color_mode: Auto
    controller_device: <my_id>
    controller_entity: sensor.bedroom_lamp_main_button_action
    controller_model: IKEA E2001/E2002 STYRBAR Remote control
    light: light.bedroom_lamp

To recap:

  1. I cannot control light colour with the Controller - IKEA E2001/E2002 STYRBAR Remote control blueprint

  2. I can control light colour if I use the Hook - Light blueprint

  3. I need 1 automation for each set of control (1 x light control, 1 x colour control = 2 automations)

  4. I cannot use the colour control automation if I disable the light control automation (both need to be enabled)

This means that if I had 5 of these IKEA buttons, I’d need 10 automations 1 each for normal light control and 1 each for colour light control. That would be really cumbersome. :sweat_smile:

Am I doing something wrong here?

Disclaimer: this is the first blueprint I am using (exception made for the blueprints coming with HA) and I am also quite a newbe in domotics…

Thanks for this blueprint.
I tried to use it with zigbee2mqtt but I have some issues with the hold functionality (for the brightness buttons).
In particular, when I hold the increase or decrease brightness button, the brightness of the associated lamp change only one or at least two times. I have to release and hold again to make other 1 or 2 steps and so on…
Looking at the events in HA, it looks like that the events are triggered many times in a very fast sequence: maybe the lamp cannot follow that pace or nearly each “increase brightness command” is interrupted by the next trigger before having the time to take effect.
I tried with a limited number of repetitions (20) or with a bigger one (200). In the second case I have the same one or two brightness changes but then the light freezes becoming unable to receive any other command (like turning it off); however I can still use the remote to control (turn on or off) another linked lamp pressing other buttons.
Would adding some delay between cycles improve the behaviour ?
Have I understood correctly the process of this specific piece of the automation? Here follow what I understood.
By default, the hold/long button press is triggered only once so normally the brightness of the lamp is changed only of one step, no matter how long the button is pressed. To “simulate” a continuos action associated with the hold/long press, the action is repeated in a cycle. The cycle is interrupted when the “release” command is received triggering another action and so interrupting the repeated action (brightness inrease/decrease in the specific example). This is made possible by the “restart” mode; otherwise the already started cycle would run up to its normal number of iterations…that’s also why we have to enter a max number of iteration as a safety net). Am I right ? Not sure of having well undestood the effect of the possible modes…

Just so you know, it’s not an issue with this template.
When long-pressing right/left, the remote itself sends payload ‘on’ before sending arrow_right_hold. That ‘on’ payload is exactly the same as when pressing up, so no way to differentiate it.

Check this out: IKEA E2001/E2002 STYRBAR remote controller - incorrect long arrows press recognition · Issue #9867 · Koenkk/zigbee2mqtt · GitHub

I’m not clear if the same happens with ZHA or deconz, since the events are received differently…

1 Like

Hi,
I have a problem with this blueprint using ZHA integration.
"Error: UndefinedError: ‘dict object’ has no attribute ‘event’ "
How can I solve?

Hi all,

For some reason my STYRBAR remote control doesn’t completely work with this specific Controller and the Light Hook, I can’t dim up and down the light intensity. On/off and color change works ok.

The controller configuration is like this:

alias: Controller - IKEA E2001/E2002 STYRBAR Remote control
description: ''
use_blueprint:
  path: EPMatt/ikea_e2001_e2002.yaml
  input:
    controller_device: cb5c88f4c4531c2164eff721669346f3
    integration: ZHA
    helper_last_controller_event: input_text.helper_last_controller_event

and the Light Hook like this:

alias: Hook - Light
description: ''
use_blueprint:
  path: EPMatt/light.yaml
  input:
    controller_device: cb5c88f4c4531c2164eff721669346f3
    controller_model: IKEA E2001/E2002 STYRBAR Remote control
    light: light.iktrburgb_sala_candeeiro_pe_duplo_187f87fe_level_light_color_on_off

Basically the configurations are as default as they can be. I looked at the code of both blueprints, compared with other blueprints for the same remote to make sense of if but I didn’t found the problem. I’m still new with automation and blueprints.

What I was trying to have is simply control an Ikea RGB bulb with the same controller it was bought with like the blueprint https://github.com/niro1987/homeassistant-config/blob/826261b62e34381eb0b60d9198fa7b9b1fab79e1/blueprints/automation/niro1987/zha_ikea_tradfri_styrbar_color.yaml does.

Does anyone as a clue about what can be the problem? Am I doing something wrong?

Thank you,
Luis Sismeiro

Note: I didn’t gave up yet and made some tests with the controller to turn on and off simple devices like a switch and I can use the hold on the left and right buttons do turn on (left) and off (right) and it works. I can’t do the same by holding on up and down buttons which for sure justifies my the problem reported.

Hi again,

I’m replying to myself to share the latest regarding the troubleshooting and fixing of the problem I reported, it may be useful in the meantime to someone and included in the official release.

I had to change in the blueprint code the strings to match what zha_event sends to the for the Up Button Hold and Down Button Hold:

button_up_long:
        - move_with_on_off_MoveMode.Up_83

button_down_long:
        - move_MoveMode.Down_83_bitmap8.0_bitmap8.0

Change this and the hold for Up and Down buttons will start to work as expected. I will try to do a merge request change or something like that if I find the way to do it.

Regards,
Luis Sismeiro

Note: Solved one problem found another one or two. After releasing the hold it didn’t stop, had to add a new fix to the blueprint:

button_up_release:
      - stop_with_on_off

button_down_release:
      - stop_with_on_off

There is also the same issue for the Left and Right release after the hold because the string sent by the zha_event has a “random” positive number for the Left and a “random” negative number for the Right. If you have any idea on how to fix if, it’s welcome.

Note 2: The release problem for Left and Right is kinda solved, it only works for this controlller when using ZHA. To work with the deCONZ and Z2M, the fix must be removed. Some condition must be included somewhere but I don’t have the knowledge for that (yet). If you know how, please tell me. The fix is getting the substring release from the zha_event:

- conditions:
  - '{{ trigger_action[:7] | string in button_left_release }}' -> on line 518

- conditions:
    - '{{ trigger_action[:7] | string in button_right_release }}' -> on line 582
1 Like

Same here.
Just does not work, no event is recorded on the helper and same error message.

Executed: July 19, 2022 at 7:54:25 PM
Error: UndefinedError: 'dict object' has no attribute 'event'

Define variables trigger_action, trigger_delta, last_controller_event
Stopped because an error was encountered at July 19, 2022 at 7:54:25 PM (runtime: 0.03 seconds)
UndefinedError: 'dict object' has no attribute 'event'