Third Reality Zigbee Button & MQTT

I have a Third Reality Zigbee Button. I want it when pressed to turn on a Zigbee plug.
Both devices are listed in Z2M and both show up in mqtt.
I have created two different automations based on the Zigbee2MQTT guide.
I can see the messages when I listen to MQTT but when the button is pressed it does not turn on the device.
Here are the two automations.

- id: "ad5509ee-7b91-42a3-ae26-5be1c74a27cf"
  alias: "Black Light ON"
  trigger:
    platform: mqtt
    topic: 'zigbee2mqtt/Black Light Button'
  condition:
    condition: template
    value_template: '{{ "single" == trigger.payload_json.click }}'
  action:
    entity_id: switch.black_light_plug
    service: switch.toggle
- id: "d5bd322e-344c-4922-ba5c-c82c84c50342"
  alias: Respond to button click
  trigger:
    platform: state
    entity_id: sensor.black_light_button_action
    to: 'single
  action:
    entity_id: switch.black_light_plug
    service: switch.toggle
  mode: single

Any help is appreciated

Z2m creates ha entities and devices. There is no need to automate via mqtt.

In any event this is very likely wrong as mqtt topics don’t generally have spaces.

Thank you for putting me on the right track.
I sort of got it figured out as shown below.
But when I restart HA it turns the light on.
I am not sure what to change so that when it restarts it is in the off mode.

- id: "ad5509ee-7b91-42a3-ae26-5be1c74a27cf"
  alias: "Black Light ON"
  trigger:
  - platform: state
    entity_id:
    - sensor.black_light_button_action
  condition: []
  action:
  - service: switch.toggle
    data: {}
    target:
      device_id: 9c3ac13e811433ef93c594540eb08c39
  mode: single   

Thanks

Look at the trace to see why it is triggering.

I’m having an issue with the same device. I can add it to Z2M but it is only creating an update and battery entity, not an action entity. I can see via MQTT Explorer that it is indeed sending the message. I’ve tried reinterviewing, deleting/reading, etc. Thoughts/ideas?

If you are using the latest version of Zigbee2MQTT (version 2.X) it no longer creates action sensors.

Here are your choices.

  1. You can re-enable the creation of action sensors in Zigbee2MQTT’s Settings → Home Assistant . This is not recommended because this feature will eventually be completely removed.
    image

  2. Use a Device Trigger. This is the recommended replacement for action sensors.

  3. You can use event entities by enabling this option in Zigbee2MQTT’s Settings → Home Assistant. Then you can use a State Trigger to listen to an event entity. There’s a tutorial for it here. FWIW, this is what I chose to do.
    image

Thank you!!! I missed this from release notes…