Mqtt error on RPI startup

in a new installation of HA (2021.1 and python 3.8) when starting Ha in the Logs tab I get this error …

Failed to connect to MQTT server due to exception: [Errno 111] Connection refused

At startup I have this automation but it doesn’t seems to work …

- alias: MQTT_STARTUP
  trigger:
  - event: start
    platform: homeassistant
  condition: []
  action:
  - data:
      payload: announce
      topic: shellies/command
    service: mqtt.publish

at the startup my shelly bulbs in the interface are not clickable.

Executing it again by hand just after starting HA everything starts working again, even after several HA restarts everything is OK.
It is only when the rasp is restarted that I get this error. Did any of you find yourself in this situation ???
Thanks

I would imagine that Home Assistant starts before your MQTT broker so the connection has not been setup when the automation fires. Probably best to put a delay in the automation.

Simon

Thanks a lot man… i’m going to try.

Bye