MQTT automations trigger when restarting or saving automation

Hi all, this is my first post, sorry if its placed in the wrong forum, or incorrectly posted! :slight_smile:

My setup:
I’m running the lastes Hassio version on a hyper-v.

My problem:
I have a Sonoff RF Bridge flashed with Tasmota, together with the MQTT mosquito broker integration.
I also have som RF remotes that i use to send commands to hassio, from the RF Bridge e.g. publish2 RFBridge/loft_button2 click
With this setup i have configured some automations that triggers when i press the remote
Example:

  • id: ‘1604939800682’
    alias: tænd_sluk baglys
    description: ‘’
    trigger:
    • platform: mqtt
      topic: RFBridge/loft_button_2
      payload: click
      condition: []
      action:
    • type: toggle
      device_id: 533a3e1fbcee453cad86da887c9ab585
      entity_id: light.baglys
      domain: light
      mode: single

This all works perfectly, but when i save a new automation from the gui, some (or all) automations that triggers from an MQTT topic will active, resulting in a spectacular light show, with cool sound effect… :slight_smile:
This also happens when restarting home assistant, and i think it’s the same if i configure scripts from the gui…
Automations/scripts without MQTT triggers doesn’t seem to be affected/trigger…

I know there might be some missing info, that is requiered for someone to help me, so please be patient and tell me, if there is anything missing from my description…

For some reason, those topics are set to retain.

When you connect to a MQTT broker, it will send you ALL retained messages it has. Meaning everytime you reconnect, it will be the same as if those messages were sent by the device.

I’m not sure why reloading automations would cause this. I don’t see why homeassistant would disconnect from the MQTT Broker when you do this. But on a restart, it makes sense.

So the question is, why are these things set with retain = true? I don’t know why you would ever want the RFBridge/loft_button_2 topic to be retained. You either were around when the button was pushed, or you weren’t.

Thx. @jocnnor. :slight_smile:

It’s true they are automatically set to retain, i’m a complete noob so i configured the RF Bridge that way at first, because at that time i only had door and window sensors connected, and for that i’t made sense…
I don’t specify retain true/false in my rules, as i remember it it’s a setting for the RF Bridge, which is then applied to all rules…

I have tried to apply the following to the RF Bridge:
buttonretain 0
powerretain 0
switchretain 0

I have also changed all my rules from:
on rfreceived#Data=90B963 do publish2 RFBridge/remote2_8 klik endon
to
on rfreceived#Data=90B963 do publish RFBridge/remote2_8 klik endon
(changed publish2 to just publish)

I then restarted everything several times, and went around the house to trigger every remote, so as to potentially change the state to “not” retained.

None of this has worked, everything still “flashes” on reboot of Hassio and on saving automations, so i guess i’m to dumb to figure out how to disable the retain state.

I have temporarily removed the “answered” status, but will add it again since jocnnor i right, but i still havent solved my problem.

Once you have published a retained message to a topic, it remains retained until you delete it (also known as purging it).

To delete a retained message you publish an empty string to the topic as a retained message. This can be done using an MQTT client (like MQTT Explorer which offers a convenient Delete feature) or directly from Home Assistant’s Developer Tools > Services page.

topic: RFBridge/loft_button_2
payload: ''
retain: true

Screenshot from 2020-11-10 12-18-30

Wuhu! Many many thanks to @123 and @jocnnor !!

Your answers/solutions solved my problem!

Now, to other Noobs, like my self, do NOT use publish2 rule on RF Bridge, unless you are dealing with a sensor, for which this might be helpful! :slight_smile: