ZHA - IKEA Tradfri Shortcut button

Struggling with this one.

My button is paired in ZHA OK, it appears in the dropbox when I setup the automation but doesn’t seem to do anything - The automation never seems to run. I have tried to use the ZHA_EVENTS listener but that doesn’t seem to return anything from any of my zigbee devices.

Not sure where to look next - any advice from anyone?

And it randomly started working about 3 hours later…

Hi,
Ikea e1812 and latest firmware 2.3.080 support double click natively (with a proper zha_event for double click). I have modified the blueprint according to the newest firmware release. I tested and it’s ok. I’m not a developer so everybody feel free to debug/optimize

blueprint:
  name: ZHA - IKEA Tradfri Shortcut button
  description: Control anything with the ikea shortcut button
  domain: automation
  input:
    shortcut_button:
      name: Device
      description: Select an IKEA shortcut button
      selector:
        device:
          integration: zha
          manufacturer: IKEA of Sweden
          model: TRADFRI SHORTCUT Button
    button_short:
      name: Single click
      description: "Choose action(s) when short pressed:"
      default: []
      selector:
        action: {}
    button_double:
      name: Double click
      description: "Choose action(s) when double pressed:"
      default: []
      selector:
        action: {}
    button_long:
      name: Long click
      description: "Choose action(s) when long pressed:"
      default: []
      selector:
        action: {}
  source_url: https://community.home-assistant.io/t/zha-ikea-tradfri-shortcut-button/261936
mode: single
max_exceeded: silent
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input "shortcut_button"
action:
  - variables:
      command: "{{ trigger.event.data.command }}"
      cluster_id: "{{ trigger.event.data.cluster_id }}"
      endpoint_id: "{{ trigger.event.data.endpoint_id }}"
      args: "{{ trigger.event.data.args }}"
  - choose:
      # short click
      - conditions:
          - "{{ endpoint_id == 1 }}"
          - "{{ cluster_id == 6 }}"
          - "{{ command == 'on' }}"
        sequence:
          - choose:
            default: !input "button_short"
          - wait_for_trigger:
              - platform: event
                event_type: zha_event
                event_data:
                  device_id: !input "shortcut_button"
                  endpoint_id: 1
                  cluster_id: 6
                  command: on
            timeout:
              seconds: 1

      # double click
      - conditions:
          - "{{ endpoint_id == 1 }}"
          - "{{ cluster_id == 6 }}"
          - "{{ command == 'off' }}"
        sequence:
          - choose:
            default: !input "button_double"
          - wait_for_trigger:
              - platform: event
                event_type: zha_event
                event_data:
                  device_id: !input "shortcut_button"
                  endpoint_id: 1
                  cluster_id: 6
                  command: off
            timeout:
              seconds: 1
      # long click
      - conditions:
          - "{{ endpoint_id == 1 }}"
          - "{{ cluster_id == 8 }}"
          - "{{ command == 'move_with_on_off' }}"
        sequence:
          - choose:
            default: !input "button_long"
          - wait_for_trigger:
              - platform: event
                event_type: zha_event
                event_data:
                  device_id: !input "shortcut_button"
                  endpoint_id: 1
                  cluster_id: 8
                  command: stop
            timeout:
              seconds: 1
2 Likes

Every time I use this blueprint I get different results. I have the feeling that here reacts to very many events and it is always a coincidence which wins.

Here is an example where I pressed the button once (!):

  1. Triggered by the event ‘zha_event’ at 29. November 2021, 09:11:48: Finished at 29. November 2021, 09:11:48 (runtime: 0.10 seconds)
  2. Triggered by the event ‘zha_event’ at 29. November 2021, 09:11:48: Stopped because only a single execution is allowed at 29. November 2021, 09:11:48 (runtime: 0.00 seconds)
  3. Triggered by the event ‘zha_event’ at 29. November 2021, 09:11:48: Stopped because only a single execution is allowed at 29. November 2021, 09:11:48 (runtime: 0.00 seconds)

I also captured a click in the events display, there also 3 ones. I attached it as a PNG

I’ve downloaded this blueprint, but I cannot get it to work. Shortcut button shows as available in deCONZ/Phoscon, but the Blueprint says “No matching devices”


Have you tried to reload the Deconz integration ?

This updated script by @ArsenioLupin is the only script that worked for me with the new firmware 2.3.080!
The original script did work for single and long press, but failed to recognise a double press. This script fixes that.

Thanks :slight_smile:

Reload didn’t work for me. Still only visible in devices, not in the blueprint drop-down menu.

I am getting regular warnings on my logs (about three times a day) when using this blueprint. Anyone having the same?

Template variable warning: 'dict object' has no attribute 'command' when rendering '{{ trigger.event.data.command }}'
Template variable warning: 'dict object' has no attribute 'cluster_id' when rendering '{{ trigger.event.data.cluster_id }}'
Template variable warning: 'dict object' has no attribute 'endpoint_id' when rendering '{{ trigger.event.data.endpoint_id }}'
Template variable warning: 'dict object' has no attribute 'args' when rendering '{{ trigger.event.data.args }}'
1 Like

Hi there,

first at all, I’m still a beginner with HA and this blueprint is the first I ever installed.

Unfortunately it does not work on my system. I downloaded, installed and configured the blueprint. After this I can configure the buttons and can turn on /off a switch.
But after approx. 5 minutes my complete “Automation” gets greyed out. I cannot do anything with it. I checked the server configuration, this sayed “ok” and I did a reboot.
After this, I got the following error message:

Logger: homeassistant.setup

Source: components/device_automation/init.py:112

First occurred: 20:59:21 (1 occurrences)

Last logged: 20:59:21

Error during setup of component automation

Traceback (most recent call last):

  File "/usr/src/homeassistant/homeassistant/components/device_automation/__init__.py", line 109, in async_get_device_automation_platform

    integration = await async_get_integration_with_requirements(hass, domain)

  File "/usr/src/homeassistant/homeassistant/requirements.py", line 58, in async_get_integration_with_requirements

    integration = await async_get_integration(hass, domain)

  File "/usr/src/homeassistant/homeassistant/loader.py", line 566, in async_get_integration

    integration = await _async_get_integration(hass, domain)

  File "/usr/src/homeassistant/homeassistant/loader.py", line 594, in _async_get_integration

    raise IntegrationNotFound(domain)

homeassistant.loader.IntegrationNotFound: Integration '' not found.



The above exception was the direct cause of the following exception:



Traceback (most recent call last):

  File "/usr/src/homeassistant/homeassistant/setup.py", line 229, in _async_setup_component

    result = await task

  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 230, in async_setup

    if not await _async_process_config(hass, config, component):

  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 635, in _async_process_config

    await async_validate_config_item(hass, raw_config),

  File "/usr/src/homeassistant/homeassistant/components/automation/config.py", line 86, in async_validate_config_item

    config[CONF_ACTION] = await script.async_validate_actions_config(

  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 241, in async_validate_actions_config

    return await asyncio.gather(

  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 298, in async_validate_action_config

    choose_conf[CONF_SEQUENCE] = await async_validate_actions_config(

  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 241, in async_validate_actions_config

    return await asyncio.gather(

  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 289, in async_validate_action_config

    config[CONF_DEFAULT] = await async_validate_actions_config(

  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 241, in async_validate_actions_config

    return await asyncio.gather(

  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 256, in async_validate_action_config

    platform = await device_automation.async_get_device_automation_platform(

  File "/usr/src/homeassistant/homeassistant/components/device_automation/__init__.py", line 112, in async_get_device_automation_platform

    raise InvalidDeviceAutomationConfig(

homeassistant.components.device_automation.exceptions.InvalidDeviceAutomationConfig: Integration '' not found
´´´

-> Is this related to this blueprint only, or do I have certain problem with my system???

I would be very nice, if someone can help me with this....

best, 
jj

I don’t know about your specific problem but you should :

Yes, thank you! Backup is no problem, I’m doing a backup on my local NAS which is working perfect.

Also I checked the configuration, which showed okay. But this did not solve the error. Since this is my first blueprint, I don’t know if I have a general issue or just with this specific blueprint…

thx
c

Hello Everyone! I am trying this blueprint, and it works with the single click only. Neither hold or double clicks work. Is it a known issue?

I’m having an issue with this blueprint as well.
Initially, I configured actions for single and double press, and only the double press action would fire, although it would fire on either single or double press. After updating the firmware (from 23.0.15 to 23.0.80) I was getting only the correct single press action. Trace shows that double press is seen and no action is taken.
Now I have configured the same action for double and long press. Single and long press now work as expected, but double press still shows no action taken. I have tried deleting and re-adding the double press action, but there is no difference.
I do not see multiple events firing after a single press. The log reflects one event.

Just like for alexs, this worked to fix the same problem. Thanks!

hi all ,
any idea how i can use this as a remote to a “ring pro ding”

In the new firmware the shortcut buttons send an ‘off’ command on a double click now. Any plans on updating this blueprint?

Hi @ll,
hi @HarvsG ,

i’m new at home assistant and have only some small automations running.
Tado with window sensor, little bit of light with a shelly & aqara mini-swich and now a Ikea shortcut button with control outlet.

I had also the issues with the double click in this blueprint.

I have listen to the zha_event and see that from my Ikea button came four commands.
on, off, move_with_on_off & stop_with_on_off

As i looked in the blueprint for my Aqara mini-switch i have notice, that this blueprint only look and react on the command.

So i try a quick and dirty combination of both scripts.
On the top the Ikea Script & button_long_release and on the buttom the Aqara Script wih the right commands.

For me it looks like it will work fine.
Maybe some one with more experience can check this and maybe based on this “quick and dirty blueprint” create a new Blueprint.

blueprint:
  name: ZHA - mein IKEA button
  description: Control anything with the ikea shortcut button
  domain: automation
  input:
    shortcut_button:
      name: Device
      description: Select an IKEA shortcut button
      selector:
        device:
          integration: zha
          manufacturer: IKEA of Sweden
          model: TRADFRI SHORTCUT Button
          multiple: false
    button_short:
      name: Single click
      description: 'Choose action(s) when short pressed:'
      default: []
      selector:
        action: {}
    button_double:
      name: Double click
      description: 'Choose action(s) when double pressed:'
      default: []
      selector:
        action: {}
    button_long:
      name: Long click
      description: 'Choose action(s) when long pressed:'
      default: []
      selector:
        action: {}
    button_long_release:
      name: Long click release
      description: 'Choose action(s) when long pressed:'
      default: []
      selector:
        action: {}
  source_url: https://community.home-assistant.io/t/zha-ikea-tradfri-shortcut-button/261936
mode: single #restart
max_exceeded: silent
trigger:
- platform: event
  event_type: zha_event
  event_data:
    device_id: !input 'shortcut_button'
    
action:
  - variables:
      command: "{{ trigger.event.data.command }}"

  - choose:
      - conditions:
          - "{{ command == 'on' }}"
        sequence: !input button_short
      - conditions:
          - "{{ command == 'off' }}"
        sequence: !input button_double
      - conditions:
          - "{{ command == 'move_with_on_off' }}"
        sequence: !input button_long
      - conditions:
          - "{{ command == 'stop_with_on_off' }}"
        sequence: !input button_long_release

Just tried this blueprint with a brand new Tradfri button - pairs perfectly with my Conbee 2 and can set up, just doesn’t work at all - get:

Triggered by the event 'zha_event' at 16 May 2022, 17:37:15
Stopped because only a single execution is allowed at 16 May 2022, 17:37:15 (runtime: 0.00 seconds)

Given lots of posts, is this a known problem/dead blueprint?

Note I’ve set up automation myself manually and it works great, so definitely an issue within the blueprint

@alphabeta279
Is it possible, that you have actually two automation running with the same button?

In my opinion “Stopped because only a single execution is allowed” means there are more the one automation with this button.