Automation using mqtt triggers when any automation is updated - bug?

I have an automation with the following trigger:

platform: mqtt
topic: weide_video

It seems that if I update any automation, the above one gets triggered. Obviously not what I intended. It should only trigger when a message with this topic is received. What am I doing wrong here?

Any ideas how to fix this?

how exactly do you update your automations?
and what’s in weide_video MQTT topic when this automation triggers?
and if you change topic’s value?

In the HA UI, if I update any automation this gets triggered (after the automations are reloaded I guess).

The payload for this mqtt topic is empty when it is being sent (it is only sent very explicitly).
The topic value doesn’t matter much because I can 100% surely say this topic was not sent at the moment the automation is triggered.

When I go to Server Control and hit the Reload Automations action, it gets triggered.

Does this topic have a retained message?

That’s what I was thinking as well. I’ll have to look at it tonight, I’m using mosquitto_pub in a python script to push the msg, not sure what flags are used.

Let’s say it has, what does reloading the automations have to do with it? I wonder, why doesn’t the automation then continuously trigger rather than on an automations reload?

did you read this?

afaik when you reload automations, each automation re-subscribes to its topic. if that topic has a retained message, the MQTT broker sends it to your automation(that’s the idea behind retained flag and that’s why you only have to use it for states) and, as your automation does not have payload it will trigger on any message, every reload/resubscribe.

restart your broker and it most certainly will. restart your HA and you’ll see the same. that’s my theory

2 Likes

Checkend and indeed, the -r was used when calling mosquitto_pub.
Removed it, should be OK now :slight_smile: