Loads of breaking changes in this z2m update, particularly if you setup z2m years ago.
Before updating to the latest z2m I’ve enabled the option “Home assistant experimental event entities” in Settings → Home Assistant Integration. I’ve left the legacy options intact for now
Restart z2m
Check the States page in Home Assistant for all of the new event.xyz_action entities that have appeared
4. In your YAML, update the old sensor.xyz_action entity name with the new event.xyz_action entity name.
In my case I don’t think any other changes are required? My event.xyz_action entities are named exactly the same as my sensor.xyz_action entities, so I only have to swap sensor for event in my YAML. And the actions themselves seem to be the same. ie “off-hold”, “single” etc
Sample YAML where I’ve only needed to swap out sensor with event:
</s> <s> - platform: state # zigbee2mqtt event</s> <s> entity_id: event.sitting_room_hue_dimmer_switch_action</s> <s> attribute: action</s> <s> to: "off-hold"</s> <s>
I’m not updating z2m yet though as I have to make this change across many YAML automations and also have to work out the impacts from the removal of legacy entity attributes; I’ve had that option enabled from day one and I think I have a lot of custom sensors and automations that rely on this.
That’s a good summary. The only thing I’d add is to make sure you have the new adapter: option set under serial: before updating or you may have issues connecting to your adapter.
I’m in the same situation as you in that the action states are deeply ingrained throughout my config and custom sensors. When I updated to 2.0.0-1 a ton of things broke and after a few hours debugging I restored to a backup of 1.40.2-1 at least get the house working again until I can figure out what to do.
I’m stuck trying to get the experimental event entities to show up in 1.40.2-1 so that I can start updating my automations, scripts and custom sensors. These event entities were neither there when I updated to 2.0.0-1 nor now since I’ve restored the add-on to a backup of 1.40.2-1 and added experimental_event_entities: true into my config. Maybe I have added this setting in the wrong place, or perhaps it is just not available in 1.40.2-1? Little trick I did’t know was that I needed homeassistant: true under socat in order for that part of the config to not just disappear on restart.
If you’re using the home assistant addon then you can change that setting in the Z2M GUI - go to Settings → Home Assistant Integration and enable Event Entities from there. After a restart of Z2M the new setting should then appear in the YAML. On my setup it seems like it might have taken 10 minutes or more for these “event.xyz” entities to appear in my list of entities in Home Assistant.
FYI I’ve been down a rabbit hole since my last post; my initial solution of swapping out sensor.xyz for event.xyz in my automations did not entirely work because this method would not detect repeat events from the same button. ie everything works fine if you have a 4-button remote and you press ON, then BRIGHTNESS UP, then BRIGHTNESS DOWN etc. But if you try to press BRIGHTNESS DOWN x 5 times then it only recognises the first press. This was the case with battery-powered Xiaomi wall switches, Xiaomi square buttons, and Xiaomi magic cubes. However the issue doesn’t seem to occur with Hue remotes or Xiaomi round buttons. Very odd.
So to solve this I refactored some automations using the Event trigger steps outlined here: Event - Home Assistant - using the event as a trigger and using conditions to detect the button / single / hold / shake etc. in this case it correctly performs an action on every button press, even repeated presses of the same button.
However over the course of this afternoon I found that ghost events were toggling lights and scenes and causing general hassle… no idea how, but ghost events like this never happened before with the old triggers. So I’ve removed those new event triggers and “gone native” with MQTT triggers such as below:
I won’t be updating to the 2.0 version for a few days until I’m sure everything is stable. I don’t think I’ve ever had to put so much research and work into a pre-migration.
I have this problem with several devices. I upgraded Z2M to 2.0.0 but am still on HA2024.12.5, so it is the Z2M upgrade that caused the problem. The MQTT action messages are there but the associated entities in HA are either missing or show no action.
Took me a while to get to this point on the page (Home Assistant):
By default, Zigbee2MQTT does not listen to the hass/status Home Assistant status topic anymore, homeassistant/status is used instead (if homeassistant.status_topic is not set in your Z2M configuration.yaml). Double check that Home Assistant is using this status topic by going to: HA → Settings → Devices & services → MQTT → Configure → Re-configure MQTT → Next; the Birth message topic should be homeassistant/status.
Next, create a single automation rule. It must be triggered by each change in status (timestamp). You then need to create a ‘Choose’ action with the action (event-type) as a condition.
Example :
triggers:
- entity_id:
- event.0x00158d0001050e0f_action
trigger: state
conditions: []
actions:
- choose:
- conditions:
- condition: state
entity_id: event.0x00158d0001050e0f_action
attribute: event_type
state: flip90
sequence:
YOUR ACTION
- condition: state
entity_id: event.0x00158d0001050e0f_action
attribute: event_type
state: flip180
sequence:
YOUR ACTION
The big advantage of this operating mode is that the state of the entities is retained. It is simpler to consolidate all the actions in a single automation rule.
Michael, thanks, I would never have found that. I thought I had worked through the recommended changes for 2.0.0, but I missed that one. Gradually seem to be getting back to normal now with this help and others here.
The problem with the action triggers is that the dropdowns under From and To don’t populate with the actions that the device sends. This is unlike using a device trigger under Zigbee2MQTT 1.14.
I really don’t want to have to maintain lists of supported actions for each device and then type them in each time, like an animal — and nor do I want to edit YAML directly :(
No need to go through the MQTT discovery phase to select the action
All available actions are listed in the event_types attribute.
All actions can be consolidated in a single automation rule
Disadvantages of MQTT triggers:
Can’t be used in a condition (e.g. hold action with condition repeat until action release)
Device identifiers are not as reliable as entity identifiers. If you need to replace or re-associate a device for any reason, you have to correct every automation.
I’ve been experiencing unwanted triggers after restarting the Zigbee2MQTT service. I backtracked with MQTT triggers as recommended
I lost actions since the update. I made this, check “Home Assistant legacy action sensors”, but my automations doesn’t work.
Zigbee2MQTT and Home Assistant restarted two times.
The action shows and is functional on the device page, but none of the automation are firing when action changes…
Thank you @ironicusername ! Not only did zigbee2mqtt break after the latest update (I had to add the adapter option because my zigbee coordinator was not findable without adding some esoteric setting - thank goodness the log message directed me to the github page with repair details) but I also had to deal with this frustrating issue of my Aqara mini switches breaking.
I implemented your suggested workaround and my buttons work again. Yes I know this is only temporary but like everyone else I have a busy life and no time to further fiddle with this at the moment. I just need this working.
I have been frustrated by breaking changes in HA for the last year. I am considering retiring my smart home (or at least migrating away from HA), as it is taking too much time to try to keep up with “enhancements” that break my HA infra.
To be clear, I appreciate HA very much. It’s a great system. But the maintenance of this platform is problematic when updates cause failures. I suppose another option is to ignore all updates (do not update anything) and just use the system as-is.