Cover sensor not retaining status

Morning all,

So I’ve been at this for nearly 2 days and I’ve read every post I can find but getting nowhere.

I have a Tasmota relay board which controls opening and closing 3 doors and it also has 3 sensors to detect if the door is open or not. This has been working fine until a recent HA update where I had to move the yaml under mqtt. The buttons are working fine but on restart of HA they report as unknown/unavailable.
I have tried playing with powerretain, switchretain etc as described in The Hookup video.

mqtt:
  broker: 192.168.*.**
  discovery: true
  username: admin
  password: !secret
  discovery_prefix: homeass
  cover:
    - name: "GarageDoor1"
      state_topic: "cmnd/doorstate/POWER1"
      command_topic: "cmnd/GarageDoor/POWER1"
      payload_open: "ON"
      payload_close: "ON"
      payload_stop: "ON"
      state_open: "ON"
      state_closed: "OFF"
      optimistic: false
      retain: false

    - name: "GarageDoor2"
      state_topic: "cmnd/doorstate/POWER2"
      command_topic: "cmnd/GarageDoor/POWER2"
      payload_open: "ON"
      payload_close: "ON"
      payload_stop: "ON"
      state_open: "ON"
      state_closed: "OFF"
      optimistic: false
      retain: false

    - name: "GarageDoor3"
      state_topic: "cmnd/doorstate/POWER3"
      command_topic: "cmnd/GarageDoor/POWER3"
      payload_open: "ON"
      payload_close: "ON"
      payload_stop: "ON"
      state_open: "ON"
      state_closed: "OFF"
      optimistic: false
      retain: false

Any advice or pointers to a post I may have missed would be greatly appreciated.

You need to get tasmota to send the state messages with the retained flag set.

Thanks for the reply. That’s the road I’ve been looking at.
For some reason, when I try and use the StateRetain cmd in the tasmota console it comes back with command unknown. I’m using tasmota 9.1.0

EDIT: looks like the firmware needs updating to use this command so will try that next

UPDATE:
I have upgraded to the latest tasmoto and have the stateretain set to on but still not working.
Is there a way to do an automation each time HA starts to get the status of the door sensor? Or just get it default to closed since they normally are?
It’s a bit frustrating when everything is working fine and update breaks something that takes hours to fix.
All other lights and switches working no problem, just these 3 door sensors.

I’m having the same issue, StateRetain and StatusRetain returns ‘command unknown’ via MQTT and console. Strange I haven’t had this issue with Tasmota before.