MQTT triggers on hassio startup

Hi there,
does anybody have an idea why my doorbell mqtt automation triggers once on each hassio startup even when the client (wemos d1 mini) is offline?
I guess it is because of a subscription message to the broker but I dont know how to change the trigger so that it doesn’t react to the subscription.

configuration.yaml

mqtt:
  broker: core-mosquitto

automations.yaml

- alias: "Doorbell notification via telegram"
  trigger:
    platform: mqtt
    topic: home/doorbell/button/pressed
    payload: 'true'
  action:
  - service: notify.telegram
    data:
      message: "The doorbell is ringing."

I think you shoud look at the wemos.
It should send the value without the retain flag.

You probably have “retain on” so the broker will resend the last state when HA restarts, just create an automation that turns off the notification one till HA has been on for a few minutes after a startup event.

1 Like

Like I said, this happened even when the wemos was offline, @VDRainer.

But nevertheless thanks for the hint @keithh666 and @VDRainer, it was the retain flag. Turning on the automation after a delay didn’t help because the retain message is then just sent a little bit later.
But defining a mqtt binary sensor with the same topic and with retain = false did the job:

binary_sensor:
  - platform: mqtt
    name: doorbell
    state_topic: home/doorbell/button/pressed
    payload_on: 'true'
    retain: false
1 Like

Hi @afe,

I am running in the same issue: did you create a binary sensor and add condition to automation to trigger only if binary sensor is ON?

Can you explain a bit better?