Zigbee2mqtt IKEA on/off-switch general use

I’m having a strange behavior with this blueprint and switch. Anyone else, too? I’m using this switch for start playing music on my sonos system. Sometimes it’s not working. In HA History, it seemed that the button is pressed, but no actions were executed. For better debugging, I added another action for a notification. The Actions are: set volume, select_source, send notification. If I press the button again, most of the time it works (starts playing music). But sometimes even pressing the button 2-3 times in a row don’t start the music nor sending me an notification. Does anyone know how to debug this in more detail? Or does anyone have the same issues and fixed it somehow?

Thanks and regards,

I had a similar issue with this blueprint. I fixed it by modifying the following part of this blueprint:

The problem seems to be the following.

  • When a button’s action is triggered, the automation is triggered and starts to run
  • Meanwhile, a few milliseconds later another command action is sent having the value ‘’ (empty)
  • the previous action - that might still run - is now cancelled (since we defined mode: restart)

change from this:

  - platform: state
    entity_id: !input "remote"
    attribute: action
  - variables:
      command: "{{ trigger.to_state.state }}"
  - choose:
    # ommited

to this:

  - platform: state
    entity_id: !input 'remote'
    attribute: action
  command: '{{ trigger.to_state.state }}'

  - condition: template
    value_template: "{{ command != ''}}"
  - choose:
    # ommited

…this fix is essentially going to ignore/filter the empty commands

I pasted the modified blueprint of mine here:


I don’t want to be too optimistic, but I just switched two of my IKEA Switches to your blueprint. And so far (today) it really worked. It seemed like you did it. I was searching and debugging everything… And if this was really it, it was just this “small thing” (I also switched to a new WiFi Infrastructure which I’m also debugging since weeks).

Three Questions: How did you find that?


Why is that? I mean, where did this “other command” came from?

Is that a general thing? Should this condition added in every Switch blueprint? (Maybe my second question will answer this directly)

I will keep an eye on my automations the next days. Thank you so much for fixing this issue.

After a couple of days of working with your blueprint, I can say: This indeed fixed my issue. Thank you very much @pavax.


1 Like

Hi @jesc - I’m glad that my fix is working for you!

How did you find that?

When I added a delay action while using the original blueprint, the action that was supposed to happen after the delay never executed.

I mean, where did this “other command” came from?

From Zigbee2Mqtt way to respond to button clicks. - When you think about it does make sense - The (ikea) buttons are not stateful but Home-Assistant has the concept of stateful entities (in the case of Z2M the remote’s action is a sensor entity) So, when a button is triggerd Z2M changes the state of that sensor (eg. on_button_short). Shortly after it changes the sensor’s state back to empy like the real-world state - the button is not pressed.

Is that a general thing? Should this condition added in every Switch blueprint? (Maybe my second question will answer this directly)

IMHO: To avoid the issue off race conditions (cancelling an already running action) - The handling/filtering of the empty command is needed for all the Zigbee2Mqtt Blueprints (and having mode: restart set)

Personally, I’d rather not want to open another “Ikea Z2M Remote Bluepint Topic” here on the forum and thus hope that the original author @fich can fix this in his version.

Until so here is mine

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Yes, again: Thank you. I was searching and debugging for weeks.

Was there an error somewhere? (I’m just curious, because I added some
homeassistant.components.sonos: debug, pysonos: debug to my configuration.yaml and couldn’t find anything (now I know that I was searching at the wrong place, but I thought, I kept an eye on any error message in my logs at that time).

Yes, it makes sense now. Thank you, for your detailed clarification.

Hope that, too. Would be good if he add the fix.

No there was no error as the max_exceeded: silent in combination with mode: restart prevents that. (and these settings makes sense for this kind of blueprint). For more information see here: https://www.home-assistant.io/docs/automation/modes/

…removing the max_exceeded: silent should result in a logger warning entry, every time the previous running automation got canceled.

PS: I updated my blueprint to be compatible with different type of ikea remotes (on/off, 5-Btn, Shortcut)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.


Hi pavax - is the blueprint still working? Just wont work on my system at all.

As of 2021.12.8 (IF I remember correctly) HA has a button entity.

This might be relevant here? I’ve seen the discussion in the comments.

This blueprint just suddenly stopped working for me as of yesterday. Cant figure out why… Had to set up manual automations for the buttons, that works, so its not the integration from z2m.

Thanks for this. Im new and this really helps.
I do have a few issues I need help with.
I have added my two kitchen lights, action1 ceiling light, action2 undercabinet lights onto each button but only the first action (kitchen ceiling) is being controlled.
Is this normal behavior?
Do I need to group these two lights somehow?

The other issue and I am not sure if it’s normal or not for this button but the short press won’t activate unless the button is pressed for several seconds. Long press doesn’t do anything.

Edit: looks like the buttom is the issue. Will be replacing it today and will report back.

Thanks for any help