MQTT availability_topic in AWS

Sorry if this topic should not be here, i am new using the forum.

I have several MQTT devices (Switches, sensors) all of them using TASMOTA firmware with MQTT and AWS IoT services as the mqtt broker, everything works find except that AWS MQTT does not support RETAINED messages, so the availability_topic that subscribe to tele/sonoff/LWT topic and use the payloads: payload_available: “Online” or payload_not_available: “Offline” only works if the TASMOTA device is powered ON after the Home Assistant instance starts.

If i restart the Home assistant service, the devices remains as OFFLINE because there is not a retained message with the last ONLINE status, so i need to restar every device after an HA restart.

I think about using another mqtt message that TASMOTA sends to look for the availability, maybe the tele/sonoff/STATE topic?

If that’s the case, could you please help me with “templating” some usable value, the complete topic looks like this:

20:50:11 MQT: tele/sonoff/STATE = {"Time":"2019-09-02T20:50:10","Epoch":12345678,"Uptime":"0T00:50:20","UptimeSec":3020,"Heap":22,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"MYWIFI","BSSId":"00:00:00:00:00:00","Channel":1,"RSSI":90,"LinkCount":1,"Downtime":"0T00:00:04"}}

Maybe filtering the Uptime or UptimeSec part of that message?

Thanks a lot in advance. Regards

Pablo