From 179351cb6bfca606dc10faf492c506aae0a7d344 Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 19 Dec 2025 08:54:59 +0100 Subject: [PATCH] add back force, fix for non-HA --- src/web/WebSchedulerService.cpp | 12 ++++++++---- src/web/WebSchedulerService.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/web/WebSchedulerService.cpp b/src/web/WebSchedulerService.cpp index fcc313bbe..c8af8f825 100644 --- a/src/web/WebSchedulerService.cpp +++ b/src/web/WebSchedulerService.cpp @@ -216,12 +216,16 @@ void WebSchedulerService::publish_single(const char * name, const bool state) { } // publish to Mqtt -void WebSchedulerService::publish() { +void WebSchedulerService::publish(const bool force) { + if (force) { + ha_configdone_ = false; + } + if (!Mqtt::enabled() || scheduleItems_->empty()) { return; } - if (Mqtt::publish_single()) { + if (Mqtt::publish_single() && force) { for (const ScheduleItem & scheduleItem : *scheduleItems_) { publish_single(scheduleItem.name, scheduleItem.active); } @@ -235,7 +239,7 @@ void WebSchedulerService::publish() { Mqtt::add_value_bool(output, (const char *)scheduleItem.name, scheduleItem.active); // create HA config - if (!ha_configdone_) { + if (Mqtt::ha_enabled() && !ha_configdone_) { JsonDocument config; config["~"] = Mqtt::base(); @@ -269,7 +273,7 @@ void WebSchedulerService::publish() { config["cmd_t"] = command_topic; Mqtt::add_ha_bool(config.as()); - Mqtt::add_ha_dev_section(config.as(), F_(scheduler), nullptr, "EMS-ESP", EMSESP_APP_VERSION, !ha_created); + Mqtt::add_ha_dev_section(config.as(), F_(scheduler), !ha_created); Mqtt::add_ha_avty_section(config.as(), stat_t, val_cond); ha_created |= Mqtt::queue_ha(topic, config.as()); diff --git a/src/web/WebSchedulerService.h b/src/web/WebSchedulerService.h index 25b561bcc..511e66ef8 100644 --- a/src/web/WebSchedulerService.h +++ b/src/web/WebSchedulerService.h @@ -78,7 +78,7 @@ class WebSchedulerService : public StatefulService { void begin(); void loop(); void publish_single(const char * name, const bool state); - void publish(); + void publish(const bool force = false); bool command_setvalue(const char * value, const int8_t id, const char * name); bool get_value_info(JsonObject output, const char * cmd); void get_value_json(JsonObject output, const ScheduleItem & scheduleItem);