Not certain ‘Set’ is the proper word here. Through HASS.Agent and mqtt, I have a sensor that watches the state of my Windows session (Locked, Unlocked, and Unknown). If I log out/lock and back into my Windows session, HA properly displays such in my Dashboard. However, if I simply reboot HA while logged into my Windows session, HA shows the state ‘Unknown’ in Dashboard card.
Upon HA start, how could I check for the proper Windows session state and set the Dashboard card?
I assume you’ve got something running on your PC to send the MQTT message. If it sets the “retain” flag, the MQTT server will resend the message to any new subscribers. So when HA restarts and reconnects to MQTT, it will be sent the latest message and can update the state.
I was not aware of HASS.Agent, but it looks interesting, so I’ve installed to check it out for myself. It looks like the default is to set the retain flag, but any sensors I add are being updated through the HA API, not MQTT. So I guess your setup is different.