diff --git a/src/SendingPromise.cpp b/src/SendingPromise.cpp index 46b7afc3..e0a893f2 100644 --- a/src/SendingPromise.cpp +++ b/src/SendingPromise.cpp @@ -7,6 +7,7 @@ SendingPromise::SendingPromise() , _property(nullptr) , _qos(0) , _retained(false) +, _setRetained(true) , _overwriteSetter(false) , _range { .isRange = false, .index = 0 } { } @@ -21,6 +22,11 @@ SendingPromise& SendingPromise::setRetained(bool retained) { return *this; } +SendingPromise &SendingPromise::setSetRetained(bool retained) { + _setRetained = retained; + return *this; +} + SendingPromise& SendingPromise::overwriteSetter(bool overwrite) { _overwriteSetter = overwrite; return *this; @@ -66,7 +72,7 @@ uint16_t SendingPromise::send(const String& value) { if (_overwriteSetter) { strcat_P(topic, PSTR("/set")); - Interface::get().getMqttClient().publish(topic, 1, true, value.c_str()); + Interface::get().getMqttClient().publish(topic, 2, _setRetained, value.c_str()); } delete[] topic; diff --git a/src/SendingPromise.hpp b/src/SendingPromise.hpp index 353d9144..350765d9 100644 --- a/src/SendingPromise.hpp +++ b/src/SendingPromise.hpp @@ -15,6 +15,7 @@ class SendingPromise { SendingPromise(); SendingPromise& setQos(uint8_t qos); SendingPromise& setRetained(bool retained); + SendingPromise& setSetRetained(bool retained); SendingPromise& overwriteSetter(bool overwrite); SendingPromise& setRange(const HomieRange& range); SendingPromise& setRange(uint16_t rangeIndex); @@ -34,6 +35,7 @@ class SendingPromise { const String* _property; uint8_t _qos; bool _retained; + bool _setRetained; bool _overwriteSetter; HomieRange _range; };