ZHA - IKEA Tradfri Shortcut button debounced

Tags: #<Tag:0x00007f32675109c8> #<Tag:0x00007f3267510770> #<Tag:0x00007f32675105b8> #<Tag:0x00007f3267510310>


Only use this blueprint if the advanced one doesn’t work for you:
This automation blueprint is for the Ikea shortcut button. This only works if u use ZHA integration to connect the shortcut button. You can add any action to the button for a short press or a long press.

Just copy the url of this post and add it to your blueprints.

Blueprint Code

  name: ZHA - IKEA Tradfri Shortcut button (debounced)
  description: Control anything with the ikea shortcut button (debounced)
  domain: automation
      name: Device
      description: Select an IKEA shortcut button
          integration: zha
          manufacturer: IKEA of Sweden
          model: TRADFRI SHORTCUT Button
      name: Single click
      description: "Choose action(s) when short pressed:"
      default: []
        action: {}
      name: Long click
      description: "Choose action(s) when long pressed:"
      default: []
        action: {}
mode: single
max_exceeded: silent
- platform: event
  event_type: zha_event
    device_id: !input 'shortcut_button'
- 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:

  # single click
  - conditions:
    - '{{ endpoint_id == 1 }}'
    - '{{ cluster_id == 6 }}'
    - '{{ command == ''on'' }}'
    - choose:
      default: !input 'button_short'
    # delay for debounce, or long press while debounce
    - wait_for_trigger:
      - platform: event
        event_type: zha_event
          device_id: !input 'shortcut_button'
          endpoint_id: 1
          cluster_id: 8
          command: move_with_on_off
        milliseconds: 750
      continue_on_timeout: false
    - choose:
      default: !input 'button_long'

  # long click
  - conditions:
    - '{{ endpoint_id == 1 }}'
    - '{{ cluster_id == 8 }}'
    - '{{ command == ''move_with_on_off'' }}'
    sequence: !input 'button_long'


  • 2021-01-08: First initial release.
1 Like

Thank you for this!

One question: Why do all buttons that use this blueprint get triggered once every hour?

[Knapp 2] has been triggered by event 'zha_event'

The “trigger” doesn’t cause activation of the set actions.

I’m just noticing this myself. After some debugging, it looks like the device sends a periodic “checkin” event that triggers the automation.

You think there’s anything one can do to stop it?

But isn’t it weird that it doesn’t actually trigger the automation actions?

It actually does trigger the actions for me. The lights turn themselves on every hour. I just realized the blueprint I’m using is a different one than in this post. I’m using the one here: ZHA - IKEA Tradfri On/Off Switch

Hm, ok. Interesting that both blueprints have this problem. Is it something that started appearing recently for you?

Wait maybe not. LOL. It looks like Ikea motion sensors send the same hourly checkin events as well, and those were triggering my lights, not the button automation.

The checkin events from the button do trigger my blueprint automation every hour, but I haven’t watched long enough to see if that actually turns my lights on.

I’m still new to all this, but from what I’ve read so far, these blueprints create automations that are triggered by events, and any event from the Ikea button will trigger the automation, including those ‘checkin’ events.

- platform: event
  event_type: zha_event
    device_id: !input 'remote'

Once the automation is triggered, the event’s data is evaluated against conditions that determine what actions should happen. The ‘checkin’ command doesn’t match any conditions in the automation, so it just gets ignored and nothing should happen.

It would be great if we could filter out those specific events so the automation doesn’t even get triggered, but I haven’t had luck editing the blueprint.

1 Like

Thanks for this blueprint. I was previously tearing my hair out with my automation running 4-5 times per button press.

Thank you for this explanation! Makes sense. I’d also like to find a way to get rid of these events, it’s harder to track actual usage of the buttons with these periodic events.