Need Help - Mqtt trigger automation

Hi,
Need help to trigger a switch on receiving an MQTT message.

- alias: 'Presence TestRoom'
  initial_state: true
  hide_entity: true
  trigger:
    platform: mqtt
    topic: home/TestRoom/prez
    payload: '1'
  condition:
    condition: time
    after: '18:00:00'
    before: '23:30:00'
  action:
    service: switch.turn_on
    entity_id: switch.bedroom_light

This automation isn’t working.

Appreciate your help.

Abhay

Not sure you can do it like that.
I have a MQTT sensor that is updated by a MQTT message and I check for the state of that to change as a trigger and then send the notification or whatever you want to do…

Thanks @DavidFW1960, used your guidance to write a different automation, and it works like a charm.
Appreciate your help.

1 Like

You should be able to do it like that. See the example here: https://www.home-assistant.io/docs/automation/trigger/#mqtt-trigger

Perhaps it was just that you had quotes around the payload, making it a string instead of a number.