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,
Jens

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:

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

to this:

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

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

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

I pasted the modified blueprint of mine here:

3 Likes

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?

And:

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.

Regards,
Jens

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: Automation modes - Home Assistant

…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.

2 Likes

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

Awesome to have a generic blueprint for the ikea remotes. Have noticed an issue where multiple actions won’t run. I.e - on action, turn on garage lights (works) & turn on wall plug (doesn’t run). Reversing those actions results in the wall plug turning on, but not the lights. Any idea what would be preventing multiple actions from running?

Cheers!

1 Like

I’m not even sure why - but for some reason this was not workin on my env.
I had to apply the follwing changes


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

to make it work.

gist available here: z2m-ikea-remote-controls.yaml · GitHub

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

That solved my 2 hours headache … Tks !!

1 Like

Thanks for this blueprint and this modification which make sense.
However, I still have the issue of a sequence of actions being stopped since the automation is restarted (which is clearly visible on the automation tracking page).

I also tried to add None as possible null value (as I found in another blueprint) but this does not resolve the issue:

condition:
  - condition: template
    value_template: "{{ command not in ["","None"] }}"

The only (temporary?) solution that I have found is to swith to queued mode.
Any guess of what is going on?

I’ve made it easier with this import button :slight_smile:

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

Thank you. I have also spent hours to find that the original blueprint stopped working.

Can someone explain why it broke?

1 Like

first of all: thanks for sharing!
I am having a problem, where when I want to turn on/off or toggle multiple devices with one click, it always only triggers the first device. anyone else knows a workaround to use with this blueprint? thanks!

same problem for me