mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 01:09:51 +03:00
Merge branch 'emsesp:dev' into dev
This commit is contained in:
@@ -405,17 +405,7 @@ void WebCustomEntityService::publish(const bool force) {
|
||||
|
||||
if (entityItem.value_type == DeviceValueType::BOOL) {
|
||||
// applies to both Binary Sensor (read only) and a Switch (for a command)
|
||||
if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) {
|
||||
config["pl_on"] = true;
|
||||
config["pl_off"] = false;
|
||||
} else if (EMSESP::system_.bool_format() == BOOL_FORMAT_10) {
|
||||
config["pl_on"] = 1;
|
||||
config["pl_off"] = 0;
|
||||
} else {
|
||||
char result[12];
|
||||
config["pl_on"] = Helpers::render_boolean(result, true);
|
||||
config["pl_off"] = Helpers::render_boolean(result, false);
|
||||
}
|
||||
Mqtt::add_ha_bool(config);
|
||||
}
|
||||
|
||||
Mqtt::add_ha_uom(config.as<JsonObject>(), entityItem.value_type, entityItem.uom); // add uom
|
||||
|
||||
@@ -280,18 +280,7 @@ void WebSchedulerService::publish(const bool force) {
|
||||
snprintf(command_topic, sizeof(command_topic), "%s/%s/%s", Mqtt::base().c_str(), F_(scheduler), scheduleItem.name.c_str());
|
||||
config["cmd_t"] = command_topic;
|
||||
|
||||
if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) {
|
||||
config["pl_on"] = true;
|
||||
config["pl_off"] = false;
|
||||
} else if (EMSESP::system_.bool_format() == BOOL_FORMAT_10) {
|
||||
config["pl_on"] = 1;
|
||||
config["pl_off"] = 0;
|
||||
} else {
|
||||
char result[12];
|
||||
config["pl_on"] = Helpers::render_boolean(result, true);
|
||||
config["pl_off"] = Helpers::render_boolean(result, false);
|
||||
}
|
||||
|
||||
Mqtt::add_ha_bool(config);
|
||||
Mqtt::add_ha_sections_to_doc(F_(scheduler), stat_t, config, !ha_created, val_cond);
|
||||
|
||||
ha_created |= Mqtt::queue_ha(topic, config.as<JsonObject>());
|
||||
@@ -346,7 +335,7 @@ bool WebSchedulerService::command(const char * name, const std::string & command
|
||||
commands(s, false);
|
||||
url.replace(q + 1, l, s);
|
||||
}
|
||||
if (!url.find("http") && http.begin(url.c_str())) {
|
||||
if (http.begin(url.c_str())) {
|
||||
// add any given headers
|
||||
for (JsonPair p : doc["header"].as<JsonObject>()) {
|
||||
http.addHeader(p.key().c_str(), p.value().as<String>().c_str());
|
||||
|
||||
@@ -614,7 +614,7 @@ std::string compute(const std::string & expr) {
|
||||
if (DeserializationError::Ok == deserializeJson(doc, cmd)) {
|
||||
HTTPClient http;
|
||||
std::string url = doc["url"] | "";
|
||||
if (!url.find("http") && http.begin(url.c_str())) {
|
||||
if (http.begin(url.c_str())) {
|
||||
int httpResult = 0;
|
||||
for (JsonPair p : doc["header"].as<JsonObject>()) {
|
||||
http.addHeader(p.key().c_str(), p.value().as<std::string>().c_str());
|
||||
|
||||
Reference in New Issue
Block a user