How to ignore old MQTT messages?

Hi there,

I have an automation which is triggered everytime there is a message in a specific MQTT topic:

  trigger:
  - platform: mqtt
    topic: /light/out

The problem is, each time HA restart or automations are reloaded it’s getting triggered even though there is no new message…
I found absolutely no way to get an automation working with only new messages.
The device who is publishing the messages is an ESP8266. The exact C++ line is:

mqttClient.publish(out_topic, String(vout).c_str(), false)

So retain flag is off during publishing.

There must still be a retained message there. Use MQTT Explorer to inspect the topic.

Send an empty retained message to that topic, or delete the retained message with MQTT Explorer.

1 Like

Thank you so much I deleted everything and now it works flawless :slight_smile: I always thought the retained messages are simply getting overwritten… But they are there practically forever until you delete them manually.

They are only overwritten by other retained messages.

They can be deleted by sending a retained empty message.