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

Hello

I set up some automation with this blueprint. They are mostly working.
But sometime I get a message like:

Triggered by the event ‘zha_event’ at August 17, 2021, 09:54:06

Test multiple conditions using “and”

Delay for {“milliseconds”:100}

Define variables trigger_action, trigger_delta

Call service input_text.set_value

Switch_Reduit_Washing_IKEA_Automation(input_text.switch_reduit_washing_ikea_automation) changed to {“trigger_action”: “checkin”, “last_triggered”: “2021-08-17 09:54:07.068562+02:00”}

Choose: No action taken

Even I did not push the button. What is the reason for that ?

I’m trying to make the double press work on my E1812 through your blueprint.
I would like my Google Nest Mini talk to me on double press (service: tts.google_say) but I’m not sure whether I need to use the Media Player blueprint on top of the main blueprint :confused:
Do I need to fill in the Helper - Last Controller Event and with what ?.. :man_shrugging:
Thank you for your pointers !

My actual goal is to double press the shortcut button and have my GNMini tell me when the next bus is (+ switching on a green or red light) which works fine with the following automation on a single click with no fancy blueprint.

alias: 'Bus : announce next bus on button click'
description: ''
trigger:
  - device_id: e89302a904a3c40c4a456307c2dca5d9
    domain: deconz
    platform: device
    type: remote_button_short_press
    subtype: ''
condition: []
action:
  - service: tts.google_say
    data:
      message: Next bus in {{ states('sensor.ratp_bry_next') }} minutes
      entity_id: media_player.salon
  - service: light.turn_on
    data:
      color_name: |
        {% if states('sensor.ratp_bry_next') | int >= 5 %}
          green
        {% else %}
          red
        {% endif %}
      brightness_pct: 100
    target:
      entity_id: light.piano_strip
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - type: turn_off
    device_id: 069b72bbf0acd6390761b775cf2f309e
    entity_id: light.piano_strip
    domain: light
mode: single

Similar to @BeastHouse I started having the same trouble with all my buttons. I’m using ZHA and have HA updated. I’ve restarted HA, deleted and remade the automations, but nothing seems to fix it. All my IKEA shortcut buttons give this error now.

Stopped because an error was encountered at December 16, 2021, 11:51:08 AM (runtime: 0.05 seconds)

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

If anyone else has the problem and found a solution I’d love to hear how. Thanks!

2 Likes

Mine stopped working as soon as I had updated HA. It was a long time ago though.

1 Like

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!