Using the new action events in Zigbee2MQTT 2.0

It seems you try to send the brightness_move mqtt command to your dimmer.

You cannot dim the dimmer. You need to create a zigbee group of lights in zigbee2mqtt and send the brightness_move commands to the mqtt topic for that group

1 Like

Yes, that’s true. I didn’t understand that part of the automation. But yeah, it makes sense, that the action is for the light and not for the dimmer. :grinning:

Thanks for that. Here is my customised automation:

alias: BĂźro Dimmer - Event Test 3
description: ""
triggers:
  - trigger: state
    entity_id: event.buro_dimmer_action
    not_from: unavailable
conditions: []
actions:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.button == 'on'}}"
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'press'}}"
        sequence:
          - data:
              brightness_pct: 90
            action: light.turn_on
            target:
              entity_id: light.spots_vorn_buro
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.button == 'on'}}"
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'hold'}}"
        sequence:
          - data:
              brightness_pct: 90
            action: light.turn_on
            target:
              entity_id:
                - light.spots_vorn_buro
                - light.spots_hinten_buro
                - light.tischleuchten_buro
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.button == 'up'}}"
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'hold'}}"
            enabled: true
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              brightness_step_pct: 10
            target:
              entity_id:
                - light.spots_vorn_buro
                - light.spots_hinten_buro
                - light.tischleuchten_buro
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.button == 'down'}}"
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'hold'}}"
            enabled: true
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              brightness_step_pct: -10
            target:
              entity_id:
                - light.spots_vorn_buro
                - light.spots_hinten_buro
                - light.tischleuchten_buro
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.button in ('up', 'down')}}"
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'hold_release'}}"
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              brightness_step_pct: 0
            target:
              entity_id:
                - light.spots_vorn_buro
                - light.spots_hinten_buro
                - light.tischleuchten_buro
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.button == 'off'}}"
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'press'}}"
        sequence:
          - data: {}
            action: light.turn_off
            target:
              entity_id: light.spots_vorn_buro
      - conditions:
          - condition: template
            value_template: "{{trigger.to_state.attributes.button == 'off'}}"
          - condition: template
            value_template: "{{trigger.to_state.attributes.event_type == 'hold'}}"
        sequence:
          - data: {}
            action: light.turn_off
            target:
              entity_id:
                - light.spots_vorn_buro
                - light.spots_hinten_buro
                - light.tischleuchten_buro
mode: queued
initial_state: "on"
max_exceeded: silent

My lights are Matter over Thread bulbs and not Zigbee bulbs. So, I can’t create Zigbee groups in zigbee2mqtt.

Compared to the old actions (Home Assistant legacy action sensors) with the same hardware constellation, it’s really slow when I dim my lights. If I press the up or down buttons several times, it sometimes takes more or less 10 seconds to reach the correct dimming level.

Do you have any idea why the dimming process is slower than with the legacy action sensors?

The lowest brightness should be 1% in my case. What do I have to do if I don’t want the light bulbs to be dimmed to off?

I would really love to have double/triple/quadruple presses on the on button. Any idea how this works?

Sorry for all the questions. :wink:

Thanks Hoppel

@KennethLavrsen Thank you again for this great summary. I’d recommend updating the examples in first post to also include “not_to: unavailable” in trigger. Not sure If I have something else wrong, but without this, as soon as I restart MQTT (update, or whatever reason), my roborock starts cleaning kitchen - which is triggered by button press. And that button event was triggering this automation when going into unavailable state. It doesn’t happen with all buttons, so maybe it’s only buttons that you not yet pressed manually, maybe it’s only when the automation doesn’t have the single/double press condition because you don’ care how many times you press it and you just want to run the automation. In any case, I believe having not_to: unavailable is wanted failsafe.

Thanks for the feedback. I added your suggested improvement to the original post

FWIW, I doubt it’s a common occurrence.

My guess is their device doesn’t publish the event entity’s state as a retained value. After a restart, the MQTT broker has no data stored for the event entity’s state value so Home Assistant reports unavailable.

I just realised that I am affected by this change.
I have read the zigbee docs and changes to v2, as well as all 180+ items in this thread.
I have made numerous changes to my yaml, but still does not work.
I know that I am missing something.
Here is my original code. Using a Third Reality button to turn a wall plug on and off.

- id: "f1abdcdd-3552-43e4-bf43-5c7f4eb4977d"
  alias: "P1P Black Light ON"
  trigger:
  - platform: state
    entity_id:
    - sensor.office_black_light_button_action
    not_from:
    - unavailable
    - unknown 
    to:      
  condition: []
  action:
  - service: switch.toggle
    data: {}
    target:
      device_id: 6058301f67e55de6cf227e877e21b1bb
  mode: single  

Any help appreciated.

Post what you tried with the event entity but failed to work.

This is what I have tried and various iterations of using device_id vs entity_id

automation:
    - alias: "P1P Black Light ON"
      triggers:
          - trigger: device
            domain: mqtt
            device_id: 214ab1d81b7ddda084984348650a7a0b
            type: action
            subtype: button_press
      actions:
          - action: switch.toggle
            target:
                entity_id: switch.3d_office_p1p_black_light_plug

OK but that’s an MQTT Device Trigger which isn’t the subject of this topic.

Go to Developer Tools → States and look for an event entity whose name suggests it’s related to your remote-control device.

If you have no event entities, or none related to the device, it implies you may not have enabled the following option in Zigbee2MQTT’s configuration.

homeassistant:
  experimental_event_entities: true

This post contains a few details about my system’s Zigbee2MQTT configuration.

1 Like

10 posts were split to a new topic: What is the point of the new event entities in Zigbee2MQTT?

Dear All,
Judging from the sheer number of posts in this Thread (190+) I can just imagine the number of hours wasted by all those good people, trying to figure out WTF is going on!
And how to handle event type entities isn’t covered anywhere in the official Home Assistant User Docs online (as far as I could see).
If it hadn’t been for the likes of @KennethLavrsen, most of us had given up by now, and the remaining rest would have ended up in a mental institution!

:no_mouth:

It’s covered in the event documentation, which is searchable, in the integration list, and linked from the MQTT Event integration page.

It has examples, including UI examples.

@petro to the rescue (as always) :blush:
I never found that section in the docs - probably because in my head an event is not an Integration. Perhaps I’m wrong…
But secondly, I tried exactly what was described there, and it never triggered! I had to follow @KennethLavrsen’s instructions and use not_from: unavailable to make it work. Something which is miles above my level.
So I continued reading the long thread until I found the tip to enable legacy - which I also would never have found on my own as it is tucked away deep down in the Z2M UI menu structure - in a place I’ve never been before.

So even if things are easy and obvious to some, it may be overwhelmingly difficult to others ( like me - and 20,40,50 others in this thread) :unamused:

I suggest you use search. It searches all the documentation, then you don’t need to know where to look.

Thank you for the great write up on this, information is hard to come by. Everything just seems to assume you spend every day dealing with the eco system which you know, I don’t. :wink:

So I upgraded to 2+ yesterday and yes, my action sensor is gone… I have a SNZB-01 button but there is no event entity, should the event entity just create and be there ready to use?

I hit the ‘legacy action sensors’ button and i got my old sensor back so I am good for now but I am happy to migrate to the new way, just it wasn’t there. So is there soemthing manual I have to do or it just doesn’t work in all cases right now?

All the information is in the first post, with examples. Take a look at it.

I am new here and trying to learn this platform. Is this issue why when I join a Third Reality button to Z2M it doesn’t work? I don’t get any commands from the button. If I click these two items will the button work as normal?