Zigbee2MQTT - Missing triggers in automation on switches/buttons

Yep moved from Mosquito to EMQX and haven’t had a single instance of this issue.

@lundy are you using the addon version of emqx? (And before that mosquito)

@nickrout exactly. Been rock solid since I moved over and it only took something like 30 minutes to do.

Update: This has now started happening with EMQX after a few months with no issues. Not sure what the deal is here.

I can confirm this is happening to me in version 2024.10.3 running in Docker, with Aqara buttons.

The triggers seem to just… vanish, and it seems like a reboot of the raspberry pi is required - a docker container restart and/or restart of HA from the UI both were not enough.

Interestingly, I notice that the event actually fires, it really is just the trigger which disappears in HA (and presumably is what breaks my automations) and the trigger also disappears in NodeRed. I see battery state changed and “identify” as the only 2 available triggers.

I’m using 3 buttons connected to my Aqara hub, connected through HomeKit.

Here’s the event firing:

event_type: state_changed
data:
  entity_id: event.moon_lamp_moon_lamp_button
  old_state:
    entity_id: event.moon_lamp_moon_lamp_button
    state: "2024-10-22T04:36:37.929+00:00"
    attributes:
      event_types:
        - single_press
        - double_press
        - long_press
      event_type: single_press
      device_class: button
      friendly_name: Moon Lamp Moon Lamp Button
    last_changed: "2024-10-22T04:36:37.929659+00:00"
    last_reported: "2024-10-22T04:36:37.929659+00:00"
    last_updated: "2024-10-22T04:36:37.929659+00:00"
    context:
      id: 01JAS86EX983YXFN5G3KKZWGD0
      parent_id: null
      user_id: null
  new_state:
    entity_id: event.moon_lamp_moon_lamp_button
    state: "2024-10-22T04:36:42.480+00:00"
    attributes:
      event_types:
        - single_press
        - double_press
        - long_press
      event_type: single_press
      device_class: button
      friendly_name: Moon Lamp Moon Lamp Button
    last_changed: "2024-10-22T04:36:42.480227+00:00"
    last_reported: "2024-10-22T04:36:42.480227+00:00"
    last_updated: "2024-10-22T04:36:42.480227+00:00"
    context:
      id: 01JAS86KBGDYK1B5YRXJHGZ1S7
      parent_id: null
      user_id: null
origin: LOCAL
time_fired: "2024-10-22T04:36:42.480227+00:00"
context:
  id: 01JAS86KBGDYK1B5YRXJHGZ1S7
  parent_id: null
  user_id: null

And I was able to convert this very simple trigger into a much more complex “manual event” but at least it should survive these triggers disappearing :frowning:

To do so:

trigger = manual event
event type = state_changed
event data = entity_id: event.moon_lamp_moon_lamp_button

then add a condition:

{{ trigger.event.data.new_state.attributes.event_type == ‘single_press’ }}

Edit:
Okay but I didn’t like the triggers and needing conditions, so I added a new event type in node red instead.

Now my trigger is:
event type = custom_aqara_notification_from_node_red
event data = entity_id: moon_lamp_button_single_pressed

And in node red I use these nodes for each button

events: state → switch → fire event (one event per button state)