Rollershutter retain

Home assistant currently does not retain numeric state of mqtt-rollershutter on restart.

I have a automation script that uses the state as a condition, so it would be nice to retain the state or poll for the state on restart.

From the MQTT Rollershutter documentation it states the following:

The mqtt rollershutter platform enables the possibility to control an MQTT rollershutter. The device state will be updated only after receiving the a new state from state_topic. If these messages are published with RETAIN flag, the MQTT device will receive an instant state update after subscription and will start with correct state. Otherwise, the initial state will be unknown.

When you publish the state of 0-100 on the state_topic you have setup, you have to set the retain: true flag at the time you publish it.

1 Like

Thanks for the reply.

I have tried setting the flag but it doesn’t work.

Looking into the source code there seems to be no implementation of “retain” despite what is written in the documentation.

Managing the retain flag is the responsibility of the device that publish to a topic. In this case that’s the rollershutter. HA is not involved in that process. It will just accept updates on the subscribed topics after a restart that are pushed by the mqtt broker. If a topic is published with retain flag set to true, the broker will send the last value of the topic upon subscription.

You should test the mqtt messaging with a third party program, eg mosquitto has a command line interface. Make sure the rollershutter is publishing with retain set to true.

Thanks for this information.
I am still learning my way through Hass and MQTT.
Your explanation here has pointed me in the right direction and I will research more on this topic.
Thank you for your prompt response.

1 Like