Homeassistant/status problem

I’m integrate my device to HA via mqtt, when i’m connect to broker and subscribe to receive HA status (homeassistant/status), i’m immediately receive ‘offline’. If restart HA, then receive offline, then online.
Why on connect i only receive offline? How to receive online on connect to mqtt broker (HA already connect to that broker). Or, how to query current HA status via mqtt?

MQTT Birth and Last will - Home Assistant — that’s not help.

The log looks like:
homeassistant/status offline
homeassistant/sensor/0x00158d0006d4ded6/battery/config {“availability”:[{“topic”:“zigbee2mqtt/bridge/state”},{“topic”:“zigbee2mqtt/Button_GardenLights/availability”}],"availability_
homeassistant/sensor/0x00158d0006d4ded6/voltage/config {“availability”:[{“topic”:“zigbee2mqtt/bridge/state”},{“topic”:“zigbee2mqtt/Button_GardenLights/availability”}],"availability_
homeassistant/sensor/0x00158d0006d4ded6/action/config {“availability”:[{“topic”:“zigbee2mqtt/bridge/state”},{“topic”:“zigbee2mqtt/Button_GardenLights/availability”}],"availability_m

Its the retain state that needs to be set correctly on your client devices.
https://www.hivemq.com/blog/mqtt-essentials-part-8-retained-messages/

Thank you, now little bit clear.

One more question - why retain offline status is retain, but when HA start and public online status - that status not retained? May be that’s bug in HA?

I assumed that the MQTT Broker was a HA addon, so the broker would restart with HA, but I might be wrong since you wrote nothing about that. :thinking:

No, MQTT Broker on separate device in network.

Hmm, you might have to ask one of the developers then, because that sounds a bit inconsistant.