mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-27 17:19:08 +03:00
publish mqtt emsesp on-change messages on connect
This commit is contained in:
@@ -378,10 +378,20 @@ void WebCustomEntityService::publish_single(CustomEntityItem & entity) {
|
||||
}
|
||||
|
||||
// publish to Mqtt
|
||||
void WebCustomEntityService::publish() {
|
||||
if (!Mqtt::enabled() || customEntityItems_->empty()) {
|
||||
void WebCustomEntityService::publish(const bool force) {
|
||||
if (!Mqtt::connected() || customEntityItems_->empty()) {
|
||||
return;
|
||||
}
|
||||
if (force) {
|
||||
if (Mqtt::publish_single()) {
|
||||
for (CustomEntityItem & entityItem : *customEntityItems_) {
|
||||
publish_single(entityItem);
|
||||
}
|
||||
return;
|
||||
} else if (!EMSESP::mqtt_.get_publish_onchange(0)) {
|
||||
return; // wait for first time periode
|
||||
}
|
||||
}
|
||||
|
||||
JsonDocument doc;
|
||||
JsonObject output = doc.to<JsonObject>();
|
||||
|
||||
Reference in New Issue
Block a user