mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-31 11:09:10 +03:00
add back force, fix for non-HA
This commit is contained in:
@@ -216,12 +216,16 @@ void WebSchedulerService::publish_single(const char * name, const bool state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// publish to Mqtt
|
// publish to Mqtt
|
||||||
void WebSchedulerService::publish() {
|
void WebSchedulerService::publish(const bool force) {
|
||||||
|
if (force) {
|
||||||
|
ha_configdone_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Mqtt::enabled() || scheduleItems_->empty()) {
|
if (!Mqtt::enabled() || scheduleItems_->empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Mqtt::publish_single()) {
|
if (Mqtt::publish_single() && force) {
|
||||||
for (const ScheduleItem & scheduleItem : *scheduleItems_) {
|
for (const ScheduleItem & scheduleItem : *scheduleItems_) {
|
||||||
publish_single(scheduleItem.name, scheduleItem.active);
|
publish_single(scheduleItem.name, scheduleItem.active);
|
||||||
}
|
}
|
||||||
@@ -235,7 +239,7 @@ void WebSchedulerService::publish() {
|
|||||||
Mqtt::add_value_bool(output, (const char *)scheduleItem.name, scheduleItem.active);
|
Mqtt::add_value_bool(output, (const char *)scheduleItem.name, scheduleItem.active);
|
||||||
|
|
||||||
// create HA config
|
// create HA config
|
||||||
if (!ha_configdone_) {
|
if (Mqtt::ha_enabled() && !ha_configdone_) {
|
||||||
JsonDocument config;
|
JsonDocument config;
|
||||||
config["~"] = Mqtt::base();
|
config["~"] = Mqtt::base();
|
||||||
|
|
||||||
@@ -269,7 +273,7 @@ void WebSchedulerService::publish() {
|
|||||||
config["cmd_t"] = command_topic;
|
config["cmd_t"] = command_topic;
|
||||||
|
|
||||||
Mqtt::add_ha_bool(config.as<JsonObject>());
|
Mqtt::add_ha_bool(config.as<JsonObject>());
|
||||||
Mqtt::add_ha_dev_section(config.as<JsonObject>(), F_(scheduler), nullptr, "EMS-ESP", EMSESP_APP_VERSION, !ha_created);
|
Mqtt::add_ha_dev_section(config.as<JsonObject>(), F_(scheduler), !ha_created);
|
||||||
Mqtt::add_ha_avty_section(config.as<JsonObject>(), stat_t, val_cond);
|
Mqtt::add_ha_avty_section(config.as<JsonObject>(), stat_t, val_cond);
|
||||||
|
|
||||||
ha_created |= Mqtt::queue_ha(topic, config.as<JsonObject>());
|
ha_created |= Mqtt::queue_ha(topic, config.as<JsonObject>());
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class WebSchedulerService : public StatefulService<WebScheduler> {
|
|||||||
void begin();
|
void begin();
|
||||||
void loop();
|
void loop();
|
||||||
void publish_single(const char * name, const bool state);
|
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 command_setvalue(const char * value, const int8_t id, const char * name);
|
||||||
bool get_value_info(JsonObject output, const char * cmd);
|
bool get_value_info(JsonObject output, const char * cmd);
|
||||||
void get_value_json(JsonObject output, const ScheduleItem & scheduleItem);
|
void get_value_json(JsonObject output, const ScheduleItem & scheduleItem);
|
||||||
|
|||||||
Reference in New Issue
Block a user