Binary sensor previous state

I have a bunch of window and door contact sensors reporting via MQTT (tasmota). After HA restart or reloading of MQTT devices, I get status “Unavailable”. There is no way I can see that can load the sensor in by having it retain previous reported. What is the typical way out of this? I’ve heard something about the RETAIN flag. How do I get my device to send such a flag?

Thanks

You need to have your Tasmota devices send retained state messages.

That way when home assistant starts it can get the last state from the mqtt broker.