read initial state, after restart, from MQTT
simply by using retain, the client will get the latest state upon subscribe
This commit is contained in:
parent
ffe4b91ac6
commit
fe5552a0b1
@ -91,6 +91,11 @@ namespace Ha {
|
||||
sprintf(commandTopic, "homeassistant/%s/esp_clock/%s/set", type, id);
|
||||
}
|
||||
|
||||
void buildConfig(JsonDocument& jsonDoc) override {
|
||||
Command::buildConfig(jsonDoc);
|
||||
jsonDoc["retain"] = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct Brightness : Command {
|
||||
@ -102,6 +107,7 @@ namespace Ha {
|
||||
|
||||
void buildConfig(JsonDocument& jsonDoc) override {
|
||||
Command::buildConfig(jsonDoc);
|
||||
jsonDoc["retain"] = true;
|
||||
jsonDoc["min"] = BRIGHTNESS_MIN;
|
||||
jsonDoc["max"] = BRIGHTNESS_MAX;
|
||||
jsonDoc["step"] = BRIGHTNESS_STEP;
|
||||
|
||||
@ -116,9 +116,6 @@ namespace Mqtt {
|
||||
for (Ha::Component* cmp : switches) {
|
||||
publishComponentConfig(*cmp);
|
||||
}
|
||||
brightnessMqtt->publishState();
|
||||
hourFormatMqtt->publishState();
|
||||
ledMqtt->publishState();
|
||||
ts.deleteTask(tPublishInit);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user