diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index b61feedec..30699a031 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -390,7 +390,7 @@ void EMSdevice::register_telegram_type(const uint16_t telegram_type_id, const ch // type: one of DeviceValueType // options: options for enum, which are translated as a list of lists // options_single: list of names -// numeric_operatpr: to divide or multiply, see DeviceValueNumOps:: +// numeric_operator: to divide or multiply, see DeviceValueNumOps:: // short_name: used in Mqtt as keys // fullname: used in Web and Console unless empty (nullptr) - can be translated // uom: unit of measure from DeviceValueUOM diff --git a/src/locale_common.h b/src/locale_common.h index 35ea7eaca..471fd097e 100644 --- a/src/locale_common.h +++ b/src/locale_common.h @@ -264,7 +264,7 @@ MAKE_PSTR(response, "response") MAKE_PSTR(tag_boiler_data_ww_mqtt, "ww") MAKE_PSTR(tag_device_data_ww_mqtt, "") -MAKE_PSTR_LIST(climate, "HA climate config creation") +MAKE_PSTR_LIST(climate, "HA climate config creation", "") // syslog MAKE_PSTR_LIST(list_syslog_level, "off", "emerg", "alert", "crit", "error", "warn", "notice", "info", "debug", "trace", "all") diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 353cc8cd9..40953a030 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -755,12 +755,8 @@ void Mqtt::publish_retain(const char * topic, const JsonObject & payload, bool r } } -void Mqtt::publish_ha(const char * topic, const JsonObject & payload) { - publish_ha(std::string(topic), payload); -} - // publish empty payload to remove the topic -void Mqtt::publish_ha(const std::string & topic) { +void Mqtt::publish_ha(const char * topic) { if (!enabled()) { return; } @@ -774,7 +770,7 @@ void Mqtt::publish_ha(const std::string & topic) { } // publish a Home Assistant config topic and payload, with retain flag off. -void Mqtt::publish_ha(const std::string & topic, const JsonObject & payload) { +void Mqtt::publish_ha(const char * topic, const JsonObject & payload) { if (!enabled()) { return; } @@ -928,7 +924,7 @@ void Mqtt::publish_ha_sensor_config(DeviceValue & dv, const std::string & model, publish_ha_sensor_config(dv.type, dv.tag, - dv.get_fullname(), + dv.get_fullname().c_str(), dv.fullname[0], dv.device_type, dv.short_name, @@ -950,7 +946,7 @@ void Mqtt::publish_system_ha_sensor_config(uint8_t type, const char * name, cons JsonArray ids = dev_json.createNestedArray("ids"); ids.add("ems-esp"); - publish_ha_sensor_config(type, DeviceValueTAG::TAG_HEARTBEAT, std::string(name), name, EMSdevice::DeviceType::SYSTEM, entity, uom, false, false, nullptr, 0, 0, 0, dev_json); + publish_ha_sensor_config(type, DeviceValueTAG::TAG_HEARTBEAT, name, name, EMSdevice::DeviceType::SYSTEM, entity, uom, false, false, nullptr, 0, 0, 0, dev_json); } // MQTT discovery configs @@ -958,7 +954,7 @@ void Mqtt::publish_system_ha_sensor_config(uint8_t type, const char * name, cons // note: some extra string copying done here, it looks messy but does help with heap fragmentation issues void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdevice::DeviceValueType uint8_t tag, // EMSdevice::DeviceValueTAG - const std::string & fullname, // fullname, already translated + const char * const fullname, // fullname, already translated const char * const en_name, const uint8_t device_type, // EMSdevice::DeviceType const char * const entity, // same as shortname @@ -971,7 +967,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdevice const int16_t dv_set_max, const JsonObject & dev_json) { // ignore if name (fullname) is empty - if (fullname.empty() || en_name == nullptr) { + if (fullname == nullptr || en_name == nullptr) { return; } @@ -1106,7 +1102,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdevice // friendly name = char ha_name[70]; - char * F_name = strdup(fullname.c_str()); + char * F_name = strdup(fullname); F_name[0] = toupper(F_name[0]); // capitalize first letter if (have_tag) { snprintf(ha_name, sizeof(ha_name), "%s %s", EMSdevice::tag_to_string(tag).c_str(), F_name); diff --git a/src/mqtt.h b/src/mqtt.h index 94584369e..1fef21aef 100644 --- a/src/mqtt.h +++ b/src/mqtt.h @@ -86,15 +86,14 @@ class Mqtt { static void publish_retain(const std::string & topic, const JsonObject & payload, bool retain); static void publish_retain(const char * topic, const std::string & payload, bool retain); static void publish_retain(const char * topic, const JsonObject & payload, bool retain); - static void publish_ha(const std::string & topic, const JsonObject & payload); static void publish_ha(const char * topic, const JsonObject & payload); - static void publish_ha(const std::string & topic); + static void publish_ha(const char * topic); static void publish_ha_sensor_config(DeviceValue & dv, const std::string & model, const std::string & brand, const bool remove, const bool create_device_config = false); static void publish_ha_sensor_config(uint8_t type, uint8_t tag, - const std::string & fullname, + const char * const fullname, const char * const en_name, const uint8_t device_type, const char * const entity,