diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index cc674b7b8..fdfef14ac 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -578,7 +578,7 @@ void EMSdevice::add_device_value(int8_t tag, // to b snprintf(entity, sizeof(entity), "%s/%s", tag_to_mqtt(tag), short_name); } - for (std::string entity_id : entityCustomization.entity_ids) { + for (const std::string & entity_id : entityCustomization.entity_ids) { // if there is an appended custom name, strip it to get the true entity name // and extract the new custom name auto custom_name_pos = entity_id.find('|'); @@ -1112,7 +1112,7 @@ void EMSdevice::generate_values_web_customization(JsonArray output) { EMSESP::webCustomizationService.read([&](WebCustomization & settings) { for (EntityCustomization entityCustomization : settings.entityCustomizations) { if (entityCustomization.device_id == device_id()) { - for (std::string entity_id : entityCustomization.entity_ids) { + for (const std::string & entity_id : entityCustomization.entity_ids) { uint8_t mask = Helpers::hextoint(entity_id.substr(0, 2).c_str()); if (mask & 0x80) { JsonObject obj = output.add(); diff --git a/src/emsdevicevalue.cpp b/src/emsdevicevalue.cpp index 97bff85f7..e3cd76cec 100644 --- a/src/emsdevicevalue.cpp +++ b/src/emsdevicevalue.cpp @@ -369,7 +369,7 @@ std::string DeviceValue::get_fullname() const { return customname; } -std::string DeviceValue::get_name(std::string & entity) { +std::string DeviceValue::get_name(const std::string & entity) { auto pos = entity.find('|'); if (pos != std::string::npos) { return entity.substr(2, pos - 2); diff --git a/src/emsdevicevalue.h b/src/emsdevicevalue.h index 0a8ee1587..b877070b8 100644 --- a/src/emsdevicevalue.h +++ b/src/emsdevicevalue.h @@ -188,7 +188,7 @@ class DeviceValue { bool get_custom_max(uint32_t & val); std::string get_custom_fullname() const; std::string get_fullname() const; - static std::string get_name(std::string & entity); + static std::string get_name(const std::string & entity); // dv state flags void add_state(uint8_t s) { diff --git a/src/system.h b/src/system.h index 23b223acf..2e980a22b 100644 --- a/src/system.h +++ b/src/system.h @@ -201,7 +201,7 @@ class System { return hostname_; } - void hostname(std::string hostname) { + void hostname(const std::string hostname) { hostname_ = hostname; } diff --git a/src/web/WebCustomizationService.cpp b/src/web/WebCustomizationService.cpp index c461b367c..8e77de4fc 100644 --- a/src/web/WebCustomizationService.cpp +++ b/src/web/WebCustomizationService.cpp @@ -75,7 +75,7 @@ void WebCustomization::read(WebCustomization & customizations, JsonObject root) // entries are in the form [optional customname] e.g "08heatingactive|heating is on" JsonArray masked_entityJson = entityJson["entity_ids"].to(); - for (std::string entity_id : entityCustomization.entity_ids) { + for (const std::string & entity_id : entityCustomization.entity_ids) { masked_entityJson.add(entity_id); } } @@ -277,7 +277,7 @@ void WebCustomizationService::customization_entities(AsyncWebServerRequest * req read([&](WebCustomization & settings) { for (EntityCustomization entityCustomization : settings.entityCustomizations) { if (entityCustomization.device_id == device_id) { - for (std::string entity_id : entityCustomization.entity_ids) { + for (const std::string & entity_id : entityCustomization.entity_ids) { uint8_t mask = Helpers::hextoint(entity_id.substr(0, 2).c_str()); std::string name = DeviceValue::get_name(entity_id); if (mask & 0x80) { diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index 00fd35aa5..96777a91e 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -152,7 +152,7 @@ void WebStatusService::checkUpgrade(AsyncWebServerRequest * request, JsonVariant JsonObject root = response->getRoot(); version::Semver200_version settings_version(EMSESP_APP_VERSION); - std::string latest_version = json["version"] | EMSESP_APP_VERSION; + const std::string latest_version = json["version"] | EMSESP_APP_VERSION; version::Semver200_version this_version(latest_version); #ifdef EMSESP_DEBUG @@ -170,7 +170,8 @@ void WebStatusService::exportData(AsyncWebServerRequest * request) { auto * response = new AsyncJsonResponse(); JsonObject root = response->getRoot(); - String type = request->getParam("type")->value(); + String type = request->getParam("type")->value(); + root["type"] = type; if (type == "settings") { JsonObject node = root["System"].to(); @@ -192,7 +193,6 @@ void WebStatusService::exportData(AsyncWebServerRequest * request) { return; } - root["type"] = type; response->setLength(); request->send(response); }