diff --git a/src/core/emsdevice.cpp b/src/core/emsdevice.cpp index 55ea4396c..df8d47830 100644 --- a/src/core/emsdevice.cpp +++ b/src/core/emsdevice.cpp @@ -105,8 +105,12 @@ const char * EMSdevice::uom_to_string(uint8_t uom) { } std::string EMSdevice::brand_to_char() { + return std::string{brand_to_cstr()}; +} + +const char * EMSdevice::brand_to_cstr() const { if (!custom_brand().empty()) { - return custom_brand(); + return custom_brand().c_str(); } switch (brand_) { case EMSdevice::Brand::BOSCH: @@ -2160,7 +2164,7 @@ void EMSdevice::mqtt_ha_entity_config_create() { if (!dv.has_state(DeviceValueState::DV_HA_CONFIG_CREATED) && dv.has_state(DeviceValueState::DV_ACTIVE) && !dv.has_state(DeviceValueState::DV_API_MQTT_EXCLUDE)) { // create_device_config is only done once for the EMS device. It can added to any entity, so we take the first - if (Mqtt::publish_ha_sensor_config_dv(dv, name().c_str(), brand_to_char().c_str(), to_string_version().c_str(), false, create_device_config)) { + if (Mqtt::publish_ha_sensor_config_dv(dv, name().c_str(), brand_to_cstr(), to_string_version().c_str(), false, create_device_config)) { dv.add_state(DeviceValueState::DV_HA_CONFIG_CREATED); create_device_config = false; // only create the main config once count++; @@ -2224,7 +2228,7 @@ bool EMSdevice::has_telegram_id(uint16_t id) const { } // return the name of the telegram type -const char * EMSdevice::telegram_type_name(std::shared_ptr telegram) { +const char * EMSdevice::telegram_type_name(const std::shared_ptr & telegram) { // see if it's one of the common ones, like Version if (telegram->type_id == EMS_TYPE_VERSION) { return "Version"; @@ -2243,7 +2247,7 @@ const char * EMSdevice::telegram_type_name(std::shared_ptr teleg // take a telegram_type_id and call the matching handler // return true if match found -bool EMSdevice::handle_telegram(std::shared_ptr telegram) { +bool EMSdevice::handle_telegram(const std::shared_ptr & telegram) { for (auto & tf : telegram_functions_) { if (tf.telegram_type_id_ == telegram->type_id) { // for telegram destination only read telegram diff --git a/src/core/system.cpp b/src/core/system.cpp index 153d5318c..7e10c7dae 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -2535,7 +2535,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output obj["name"] = emsdevice->name(); // custom name obj["deviceID"] = Helpers::hextoa(emsdevice->device_id()); obj["productID"] = emsdevice->product_id(); - obj["brand"] = emsdevice->brand_to_char(); + obj["brand"] = emsdevice->brand_to_cstr(); obj["version"] = emsdevice->version(); obj["entities"] = emsdevice->count_entities(); char result[1000];