Mqtt birth message to early

Hi,

i set up the mqtt birth and will messages.
I use them to send the availablity message from my sensors (Arduino/ESP8266).

it works if i manually pubish “online” to hass/status. But the sensors are unavailable if i restart homeassistant.

birth_message:
  topic: 'hass/status'
  payload: 'online'
will_message:
  topic: 'hass/status'
  payload: 'offline'

Any idea how to solve that?

The configuration you have shown is for messages sent from HA, which will have no effect on the availability of sensors. To make the sensors available, the sensor must send a message corresponding to the availability topic for that sensor.

Alternatively, you can remove the availability topic altogether from a sensor configuration, which removes the need to send it.

Blockquote
The configuration you have shown is for messages sent from HA, which will have no effect on the availability of sensors. To make the sensors available, the sensor must send a message corresponding to the availability topic for that sensor.

i know. My Sensors react to this message and send their availability

The normal approach to this is to set the retain flag for the availability messages from your sensors. The broker will then send the messages to HA when it subscribes to the topic after a restart.

The problem you may be having is that the availability messages could be sent before HA has subscribed to them, and so they don’t get received at all.

I will try that
Thank you very much