mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
move 6x identical code to one function add_ha_bool
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
|
||||
|
||||
Reference in New Issue
Block a user