🎮 ZHA, deCONZ, Zigbee2MQTT - Ikea E1812 Shortcut button Universal blueprint - all actions + double click events - control lights, media players and more with Hooks

I was having trouble with the double press and long press using ZHA. Got them fixed with some simple code changes, just sharing here in case others find it useful:

In blueprints/automation/EPMatt/ikea_e1812.yaml
First change the variables:

    zha:
      button_short:
      - 'on'
      button_long:
      - 'stop_with_on_off'
      button_release:
      - stop
      button_double:
      - 'off'

Then add a variable:

button_double: '{{ actions_mapping[integration_id]["button_double"] }}'

Finally add an action at the end of the file:

  - conditions: '{{ trigger_action | string in button_double }}'
    sequence:
    - event: ahb_controller_event
      event_data:
        controller: '{{ controller_id }}'
        action: button_double
    - choose:
      - conditions: '{{ button_long_loop }}'
        sequence:
        - repeat:
            while: '{{ repeat.index < button_long_max_loop_repeats | int }}'
            sequence: !input 'action_button_double'
      default: !input 'action_button_double'
3 Likes

I’ve paired my Tradfri shortcut button, set up the helper and selected the controller, but this blueprint just doesn’t appear to work - listening on zha_event fires nothing, so appears dud.

Any ideas on how to fix?

Thanks for the BP! Single press and long press are working via Z2M but for some reason double press doesn’t work, when I view the traces I see the first tap causes the single press event to run, the delay is executed to wait for the potential second tap and although the second one runs it fails the first condition so I assume that’s why the first event still runs after the delay completes. Initially I was running the original firmware version it shipped with (2.3.015) and just upgraded to 2.3.080 but no change in behaviour. Any ideas?

The below is the trave for the second press.

stupid question I know, but if adding multiple shortcut buttons, do I need to use a different input helper?

Hi!

Im trying to get this to work, but i only get this message:

UndefinedError: ‘dict object’ has no attribute ‘event’

I’m using a Conbee 2 and a raspberry pi4. I think that i have created the input_text file correctly via the helpers section.
Any ideas?

// Mattias

SOLVED
Updated my Ikea button with this guide: OTA Device Firmware Updates ¡ zigpy/zigpy Wiki ¡ GitHub

Another issue now. Short press works. It fires the event and turn on a lamp. Long press and double press doesn’t work properly. In the history log for my button it fires the event for long press and double press. But nothing actually happens with my lamp.

Same issue for me, after updating to 2.3.080 double click no longer registers. I don’t even see the events in the log. Has anyone been able to work around this?
Edit: I should mention that single click and long press events work fine and show up in the log correctly.

1 Like

Has anyone got this to successfully work with Zigbee2MQTT?

I have the Shortcut button working through Zigbee2MQTT fine and I can setup a basic automation to switch on a light. This blueprint is ideal but when setup it just doesn’t trigger the required action. You can see the button is being pressed in the Blueprint events.


You’ve got to set the 'Helper - Last Controller Event" entity.

1 Like

Hi, can this blueprint be used for multiple entities as trigger ? I tried the comma-delimited way

controller_entity: sensor.swmgate_tra_sc01_action, sensor.swmgate_tra_sc02_action

but it doesnt work. Any advice, please ? Thank you

If someone has double press problem: Try to set it to 1500 ms and press slowly (1 press per second). It did the trick for me.

On Longpress of the E1812 I receive the following events via zha_event:

Long Press ZHA Event
data:
  device_ieee: b4:e3:f9:ff:fe:79:21:f0
  unique_id: b4:e3:f9:ff:fe:79:21:f0:1:0x0008
  device_id: 1e184c7cfb80703816ffd2d885a0a7bf
  endpoint_id: 1
  cluster_id: 8
  command: move_with_on_off
  args:
    - 0
    - 83
  params:
    move_mode: 0
    rate: 83
origin: LOCAL
time_fired: "2023-03-31T15:09:21.470358+00:00"
context:
  id: 01GWW3EKNY472W9P810Z8381G8
  parent_id: null
  user_id: null```

The automation will store the trigger_action as follows:

trigger_action: '{{ trigger.event.data.command }}{{"_" if trigger.event.data.args|length > 0}}{{ trigger.event.data.args|join("_") }}' 

Later in that automation the trigger_action is evaluated against the button_long variable, which for ZHA is defined as follows:

button_long: [move_with_on_off_0_83]

For some reason the automation however picks up the above shown zha_event and evaluates that to move_with_on_off_MoveMode.Up_83. Can somebody explain what is happening here?
The template to create the trigger_action variable clearly is appending the trigger.event.data.command which is move_with_on_off by _ followed by the trigger.event.data.args separated by further _, if there are any args.
So I would expect the string to be move_with_on_off_0_83 and the automation to work… but somehow it is not.

Edit: I found this on Github and ammended my automation with the proposed changes. The automation is now working.

I just added this blueprint with deconz as the integration. It appears that the double-click is exposed as a discrete event in Deconz with code 2004. What would be needed to modify the blueprint to recognize 2004 as double-click instead of the virtual version?

From what I can tell, the deconz codes are 1002 (single click), 2004 (double click), 1001 (hold/long press), 1003 (release/long press).

The double-click DeConz event is:

deconz Double Click

event_type: deconz_event
data:
id: tradfri_shortcut_button
unique_id: 38:5b:44:ff:fe:a7:cd:cf
event: 2004
device_id: 3b5a83f61448b6c23560107697d66997
origin: LOCAL
time_fired: “2023-06-02T17:19:14.879100+00:00”
context:
id: 01H1YHXQDZ2SM8K4XRHP02H4J3
parent_id: null
user_id: null

Thanks! Great blueprint and very useful.

Anyone ever get the double press to work. I can only get single and long press to work.

Tried the mentioned above slow press and increasing the time but no luck.

There is an issue with the regex used in these blueprints for the Ikea buttons after a HA release. It doesn’t look like these blueprints are being actively maintained as it was last updated over a year ago.

Please see the following post and thread that has the fix which involves you updating the blueprint file and removing some spaces from the regex statement:

Unfortunately no joy here. Tried, looked over all the posts and doesn’t seem to work for the shortcut button.

Update: I was able to pick another blueprint that was straight forward and worked perfectly!

could you please provide a link to the blueprint you used?

Hi guys,
I added this blueprint to my HA and everything work but double press function not work. Anyone can help me please?

Hello @Vanessa

This is the link to the Blueprint I used and has been working great!

https://community.home-assistant.io/t/z2m-ikea-tradfri-shortcut-button-e1812-universal-actions/522409

i found this fork with some bug fixes: https://github.com/kanflo/awesome-ha-blueprints/blob/fe4e058d71bc1a51ad0038e91cadf5f63fab3014/blueprints/controllers/ikea_e1812/ikea_e1812.yaml

ZHA: Short press & Long Press now working. Double Press still not working