Home assistant restart - how to update UI with all devices statuses

while my MQTT devices are still connected to the broker, restarting HASS makes it start out of sync of the devices’ statuses.

what is the best way to synchronize HASS UI with all of them after restart?

If your MQTT devices publish retained messages to the broker, they will be stored by the broker and will be available to Home Assistant, or any MQTT client, when it connects to the broker.

https://www.hivemq.com/blog/mqtt-essentials-part-8-retained-messages/

If they are Tasmota, there is an automation you can use to get the status on restart. It’s in their Wiki. Otherwise, they will update with the next tele update - up to 5 mins…

Brilliant - thx!

This seems to work for Tasmota and bare Shelly devices:

# Get MQTT status on start
- alias: "MQTT State on HA Restart"
  initial_state: true
  trigger:
    platform: homeassistant
    event: start
  action:
# Get Tasmota MQTT status
    - service: mqtt.publish
      data:
        topic: "cmnd/sonoffs/backlog"
        payload: "power1 ;power2 ;power3 ;power4 ;power5; dimmer; state "
# Get Shelly MQTT status
    - service: mqtt.publish
      data:
        topic: "shellies/command"
        payload: "update"