feat: added will msg for mqtt broker

This commit is contained in:
Yurii
2024-11-11 09:29:19 +03:00
parent fda18cdb13
commit ed50208546

View File

@@ -196,6 +196,11 @@ protected:
this->client->stop();
this->client->setId(networkSettings.hostname);
this->client->setUsernamePassword(settings.mqtt.user, settings.mqtt.password);
this->client->beginWill(this->haHelper->getDeviceTopic(F("status")).c_str(), 7, true, 1);
this->client->print(F("offline"));
this->client->endWill();
this->client->connect(settings.mqtt.server, settings.mqtt.port);
this->lastReconnectTime = millis();
this->yield();