MQTT Automation does not trigger

I have this simple automation running:

- id: '1554505149334'
  alias: MQTT-Forward
  trigger:
  - platform: mqtt
    topic: tele/sonoff_rf/RESULT
  action:
  - event: HASS_MQTT
    event_data_template:
      topic: '{{ trigger.topic }}'
      payload: '{{ trigger.payload }}'

But for some reason the automation is newer triggered.
There is the correct message on the mqtt server:
00:24:39 MQT: tele/sonoff_rf/RESULT = {“RfReceived”:{“Sync”:12890,“Low”:430,“High”:1230,“Data”:“009363”,“RfKey”:“None”}}

Can anyone help figuring out where the problem is?

unless there’s been some changes I’m not aware of,

change event_data_template to data_tempate

and event: HASS_MQTT to event: mqtt.publish

also just as another bit of troubleshooting make sure that the automation state is ‘on’.

Or just add " intial_state: ‘on’ " to your automation and then reload the automations.

The idea is that I whant to fire an event to AppDeamon when I get the message on MQTT. When I trigger the automation manually (in the GUI), the event is fired and start the AppDeamon ceode fine. The problem is that for some reason, the automation is not trigered when I write the events to MQTT. I have many other thing working fine with the MQTT, so the proplem is alone in the trigering. The automation is on.

With your automation it shouldn’t actually work manually because there is no trigger causing the automation to fire and should actually cause it to fire with an error. Its looking for a trigger and when manually fired it doesn’t exist.

I performed an experiment using the following two automations:

- alias: 'MQTT Event Transmitter'
  trigger:
  - platform: mqtt
    topic: test/event
  action:
  - event: HASS_MQTT
    event_data_template:
      topic: '{{ trigger.topic }}'
      payload: '{{ trigger.payload }}'

- alias: 'MQTT Event Receiver'
  trigger:
  - platform: event
    event_type: HASS_MQTT
  action:
  - service: light.toggle
    entity_id: light.family

I published a payload (any kind of payload) to the topic test/event, the first automation triggered and generated an event (HASS_MQTT) which triggered the second automation and toggled the light in our family room. It all works as expected.

Your automation should work. How are you confirming it is not triggering? Maybe whatever is supposed to detect the event HASS_MQTT is at fault.

That’s not correct.

When you trigger the automation from the GUI it doesn’t care at all about the trigger in the automation.That’s the point of being able to trigger it manually in the first place. If you had to have the configured trigger present for it to work manually then that wouldn’t make sense.

The problem was in where I put the automation yaml. Nothing wrong with the automation code.
Thank you all for your help :slight_smile:

Where was it?

For now i wrote the code directly into configuration.yaml

The two automations that I tested (shown in my previous post) were located in automations.yaml. My configuration.yaml file contains:

automation: !include automations.yaml

where was it before now?