Hypfer / Valetudo

Cloud replacement for vacuum robots enabling local-only operation
https://valetudo.cloud
Apache License 2.0
6.72k stars 397 forks source link

Add 'clean' parameter to MQTT configuration (allow persistent connection) #640

Closed bkk87 closed 3 years ago

bkk87 commented 3 years ago

When MQTT settings are configured, Valetudo will subscribe to several topics during start-up, e.g. valetudo/rockrobo/command.

In Valetudo, it is possible to specify a 'global' QoS parameter. The QoS parameter is correctly set when subscribing or publishing to a topic.

However, what is currently not possible is to set the 'clean' parameter of mqtt.js for topic subscription. See: https://github.com/mqttjs/MQTT.js

The current default in Valetudo is clean = true which means that all messages are deleted when the robot re-establishes a new connection at the MQTT broker.

Being able to set clean = false is especially useful when setting QoS to 1 or 2 because this would allow for offline messages. Example:

Hypfer commented 3 years ago

This is not abug

Hypfer commented 3 years ago

With clean = false the robot would see the previous command and start cleaning.

Would it ever stop executing that previous command or just repeat that every time a connection to the broker is established?

bkk87 commented 3 years ago

If I read the specs correctly then the robot would just start cleaning once and the message is removed/"processed".

The "clean" parameter is different to the "retain" parameter in mqtt. "retain" will always hold the last message and not delete it.

Also, when using the clean parameter, one can configure in e.g. mosquitto that the session will at some point be removed in case the robot does not connect back to the broker (persistent_client_expiration).