You’re welcome!
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.
For more information about the Solution tag, refer to guideline 21 in the FAQ.
It needs to publish its payload as a retained message.
Because they weren’t published as retained messages. The broker doesn’t keep a copy of the topic’s payload. So when a client, like Home Assistant, disconnects from the broker and then reconnects and subscribes to the topic, the broker has no stored payload to give to the client. The client will only get the next payload that is published.