From d09e2237ee477f77bca9eff3f7b928edec574f42 Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 5 Mar 2022 16:21:00 +0100 Subject: [PATCH] sonar recommendations --- .gitignore | 1 + scripts/run_sonar.sh | 2 +- src/analogsensor.cpp | 10 +++--- src/command.cpp | 17 ++++------ src/command.h | 8 ++--- src/console.cpp | 4 +-- src/dallassensor.cpp | 6 ++-- src/dallassensor.h | 4 +-- src/devices/thermostat.cpp | 39 +++++------------------ src/emsdevice.cpp | 48 ++--------------------------- src/helpers.cpp | 4 +-- src/mqtt.cpp | 2 +- src/mqtt.h | 2 +- src/system.cpp | 6 ++-- src/system.h | 2 +- src/telegram.h | 6 ++-- src/web/WebAPIService.cpp | 2 +- src/web/WebCustomizationService.cpp | 2 +- src/web/WebDataService.cpp | 4 +-- src/web/WebLogService.cpp | 2 +- 20 files changed, 51 insertions(+), 120 deletions(-) diff --git a/.gitignore b/.gitignore index 2d76fc27d..ed0708caf 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ scripts/__pycache__ # sonar .scannerwork/ sonar/ +build_wrapper_output_directory/ diff --git a/scripts/run_sonar.sh b/scripts/run_sonar.sh index a667c6884..713fbaa9f 100755 --- a/scripts/run_sonar.sh +++ b/scripts/run_sonar.sh @@ -4,5 +4,5 @@ # export SONAR_TOKEN="" make clean -build-wrapper-linux-x86-64 --out-dir sonar/build_wrapper_output_directory make all +build-wrapper-linux-x86-64 --out-dir build_wrapper_output_directory make all sonar-scanner diff --git a/src/analogsensor.cpp b/src/analogsensor.cpp index 9eeb66210..8c42fdd55 100644 --- a/src/analogsensor.cpp +++ b/src/analogsensor.cpp @@ -64,12 +64,11 @@ void AnalogSensor::reload() { // load the list of analog sensors from the customization service // and store them locally and then activate them EMSESP::webCustomizationService.read([&](WebCustomization & settings) { - auto sensors = settings.analogCustomizations; - auto it = sensors_.begin(); + auto it = sensors_.begin(); for (auto & sensor_ : sensors_) { // update existing sensors bool found = false; - for (auto & sensor : sensors) { //search customlist + for (const auto & sensor : settings.analogCustomizations) { //search customlist if (sensor_.id() == sensor.id) { // for output sensors set value to new start-value if ((sensor.type == AnalogType::COUNTER || sensor.type >= AnalogType::DIGITAL_OUT) @@ -90,10 +89,11 @@ void AnalogSensor::reload() { } it++; } + // add new sensors from list - for (auto & sensor : sensors) { + for (const auto & sensor : settings.analogCustomizations) { bool found = false; - for (auto & sensor_ : sensors_) { + for (const auto & sensor_ : sensors_) { if (sensor_.id() == sensor.id) { found = true; } diff --git a/src/command.cpp b/src/command.cpp index 34358bbdc..75ee3ccc1 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -151,7 +151,7 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec return_code = Command::call(device_type, command_p, Helpers::itoa((int16_t)data.as(), data_str), is_admin, id_n, output); } else if (data.is()) { char data_str[10]; - return_code = Command::call(device_type, command_p, Helpers::render_value(data_str, (float)data.as(), 2), is_admin, id_n, output); + return_code = Command::call(device_type, command_p, Helpers::render_value(data_str, data.as(), 2), is_admin, id_n, output); } else if (data.isNull()) { return_code = Command::call(device_type, command_p, "", is_admin, id_n, output); // empty, will do a query instead } else { @@ -160,23 +160,18 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec return return_code; } -const std::string Command::return_code_string(const uint8_t return_code) { +std::string Command::return_code_string(const uint8_t return_code) { switch (return_code) { case CommandRet::ERROR: return read_flash_string(F("Error")); - break; case CommandRet::OK: return read_flash_string(F("OK")); - break; case CommandRet::NOT_FOUND: return read_flash_string(F("Not Found")); - break; case CommandRet::NOT_ALLOWED: return read_flash_string(F("Not Authorized")); - break; case CommandRet::FAIL: return read_flash_string(F("Failed")); - break; default: break; } @@ -367,7 +362,7 @@ bool Command::list(const uint8_t device_type, JsonObject & output) { } sorted_cmds.sort(); - for (auto & cl : sorted_cmds) { + for (const auto & cl : sorted_cmds) { for (const auto & cf : cmdfunctions_) { if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && cf.description_ && (cl == read_flash_string(cf.cmd_))) { output[cl] = cf.description_; @@ -396,7 +391,7 @@ void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbo // if not in verbose mode, just print them on a single line if (!verbose) { - for (auto & cl : sorted_cmds) { + for (const auto & cl : sorted_cmds) { shell.print(cl); shell.print(" "); } @@ -406,7 +401,7 @@ void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbo // verbose mode shell.println(); - for (auto & cl : sorted_cmds) { + for (const auto & cl : sorted_cmds) { // find and print the description for (const auto & cf : cmdfunctions_) { if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && cf.description_ && (cl == read_flash_string(cf.cmd_))) { @@ -543,7 +538,7 @@ void Command::show_all(uuid::console::Shell & shell) { // e.g. //one/two////three/// becomes /one/two/three std::string SUrlParser::path() { std::string s = "/"; // set up the beginning slash - for (std::string & f : m_folders) { + for (const std::string & f : m_folders) { s += f; s += "/"; } diff --git a/src/command.h b/src/command.h index 0da1a8a90..3ff3c3c38 100644 --- a/src/command.h +++ b/src/command.h @@ -125,7 +125,7 @@ class Command { static const char * parse_command_string(const char * command, int8_t & id); - static const std::string return_code_string(const uint8_t return_code); + static std::string return_code_string(const uint8_t return_code); private: static uuid::log::Logger logger_; @@ -134,13 +134,13 @@ class Command { inline static uint8_t message(uint8_t error_code, const char * message, const JsonObject & output) { output.clear(); - output["message"] = (const char *)message; + output["message"] = message; return error_code; } }; -typedef std::unordered_map KeyValueMap_t; -typedef std::vector Folder_t; +using KeyValueMap_t = std::unordered_map; +using Folder_t = std::vector; class SUrlParser { private: diff --git a/src/console.cpp b/src/console.cpp index 256d16fa2..9a08fe2e6 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -467,7 +467,7 @@ void Console::load_standard_commands(unsigned int context) { flash_string_vector{F("test")}, flash_string_vector{F_(name_optional), F_(data_optional)}, [](Shell & shell, const std::vector & arguments) { - if (arguments.size() == 0) { + if (arguments.empty()) { Test::run_test(shell, "default"); } else if (arguments.size() == 1) { Test::run_test(shell, arguments.front()); @@ -487,7 +487,7 @@ void Console::load_standard_commands(unsigned int context) { flash_string_vector{F_(debug)}, flash_string_vector{F_(name_optional)}, [](Shell & shell, const std::vector & arguments) { - if (arguments.size() == 0) { + if (arguments.empty()) { Test::debug(shell, "default"); } else { Test::debug(shell, arguments.front()); diff --git a/src/dallassensor.cpp b/src/dallassensor.cpp index 00dfc2251..a71c79a3d 100644 --- a/src/dallassensor.cpp +++ b/src/dallassensor.cpp @@ -354,7 +354,7 @@ bool DallasSensor::command_commands(const char * value, const int8_t id, JsonObj // creates JSON doc from values // returns false if there are no sensors bool DallasSensor::command_info(const char * value, const int8_t id, JsonObject & output) { - if (sensors_.size() == 0) { + if (sensors_.empty()) { return false; } @@ -535,8 +535,8 @@ std::string DallasSensor::Sensor::name() const { bool DallasSensor::Sensor::apply_customization() { EMSESP::webCustomizationService.read([&](WebCustomization & settings) { auto sensors = settings.sensorCustomizations; - if (sensors.size() != 0) { - for (auto & sensor : sensors) { + if (sensors.empty()) { + for (const auto & sensor : sensors) { #if defined(EMSESP_DEBUG) LOG_DEBUG(F("Loading customization for dallas sensor %s"), sensor.id_str.c_str()); #endif diff --git a/src/dallassensor.h b/src/dallassensor.h index f6add0adf..c9567e32f 100644 --- a/src/dallassensor.h +++ b/src/dallassensor.h @@ -85,7 +85,7 @@ class DallasSensor { bool get_value_info(JsonObject & output, const char * cmd, const int8_t id); // return back reference to the sensor list, used by other classes - const std::vector sensors() const { + std::vector sensors() const { return sensors_; } @@ -102,7 +102,7 @@ class DallasSensor { } bool have_sensors() { - return (sensors_.size() > 0); + return (!sensors_.empty()); } size_t no_sensors() { diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index e669d2815..561bb2a82 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -325,7 +325,7 @@ std::shared_ptr Thermostat::heating_circuit(std::sha */ // if it's the first set the status flag - if (heating_circuits_.size() == 0) { + if (heating_circuits_.empty()) { strlcpy(status_, "online", sizeof(status_)); } @@ -489,65 +489,44 @@ std::string Thermostat::mode_tostring(uint8_t mode) { switch (mode) { case HeatingCircuit::Mode::OFF: return read_flash_string(F_(off)); - break; case HeatingCircuit::Mode::MANUAL: return read_flash_string(F_(manual)); - break; case HeatingCircuit::Mode::DAY: return read_flash_string(F_(day)); - break; case HeatingCircuit::Mode::NIGHT: return read_flash_string(F_(night)); - break; case HeatingCircuit::Mode::ECO: return read_flash_string(F_(eco)); - break; case HeatingCircuit::Mode::COMFORT: return read_flash_string(F_(comfort)); - break; case HeatingCircuit::Mode::HEAT: return read_flash_string(F_(heat)); - break; case HeatingCircuit::Mode::HOLIDAY: return read_flash_string(F_(holiday)); - break; case HeatingCircuit::Mode::NOFROST: return read_flash_string(F_(nofrost)); - break; case HeatingCircuit::Mode::AUTO: return read_flash_string(F_(auto)); - break; case HeatingCircuit::Mode::SUMMER: return read_flash_string(F_(summer)); - break; case HeatingCircuit::Mode::OFFSET: return read_flash_string(F_(offset)); - break; case HeatingCircuit::Mode::DESIGN: return read_flash_string(F_(design)); - break; case HeatingCircuit::Mode::MINFLOW: return read_flash_string(F_(minflow)); - break; case HeatingCircuit::Mode::MAXFLOW: return read_flash_string(F_(maxflow)); - break; case HeatingCircuit::Mode::ROOMINFLUENCE: return read_flash_string(F_(roominfluence[0])); - break; case HeatingCircuit::Mode::FLOWOFFSET: return read_flash_string(F_(flowtempoffset[0])); - break; case HeatingCircuit::Mode::TEMPAUTO: return read_flash_string(F_(tempauto)); - break; case HeatingCircuit::Mode::NOREDUCE: return read_flash_string(F_(noreduce)); - break; default: - case HeatingCircuit::Mode::UNKNOWN: return read_flash_string(F_(unknown)); - break; } } @@ -1947,9 +1926,7 @@ bool Thermostat::set_mode_n(const uint8_t mode, const uint8_t hc_num) { set_mode_value = 1; break; - default: - case HeatingCircuit::Mode::AUTO: - case HeatingCircuit::Mode::ECO: + default: // AUTO & ECO set_mode_value = 2; break; } @@ -2504,7 +2481,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co factor = 1; break; default: - case HeatingCircuit::Mode::AUTO: + // HeatingCircuit::Mode::AUTO: uint8_t mode_ = hc->get_mode(); if (mode_ == HeatingCircuit::Mode::MANUAL) { offset = 0x0A; // manual offset @@ -2543,7 +2520,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co offset = EMS_OFFSET_RC20_2_Set_temp_day; break; default: - case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code + // automatic selection, if no type is defined, we use the standard code uint8_t mode_ = hc->get_mode(); if (mode_ == HeatingCircuit::Mode::NIGHT) { offset = EMS_OFFSET_RC20_2_Set_temp_night; @@ -2614,7 +2591,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co factor = 1; break; default: - case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code + // automatic selection, if no type is defined, we use the standard code validate_typeid = monitor_typeids[hc->hc()]; //get setpoint roomtemp back if (model == EMS_DEVICE_FLAG_RC35) { uint8_t mode_ = hc->get_mode(); @@ -2650,7 +2627,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co offset = EMS_OFFSET_JunkersSetMessage_day_temp; break; default: - case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code + // automatic selection, if no type is defined, we use the standard code uint8_t modetype = hc->get_mode_type(); if (modetype == HeatingCircuit::Mode::NIGHT || modetype == HeatingCircuit::Mode::ECO) { offset = EMS_OFFSET_JunkersSetMessage_night_temp; @@ -2677,7 +2654,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co offset = EMS_OFFSET_JunkersSetMessage2_heat_temp; break; default: - case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code + // automatic selection, if no type is defined, we use the standard code uint8_t modetype = hc->get_mode_type(); if (modetype == HeatingCircuit::Mode::NIGHT || modetype == HeatingCircuit::Mode::ECO) { offset = EMS_OFFSET_JunkersSetMessage2_eco_temp; @@ -2695,7 +2672,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co if (offset != -1) { // add the write command to the Tx queue. value is *2 // post validate is the corresponding monitor or set type IDs as they can differ per model - write_command(set_typeid, offset, (uint8_t)((float)temperature * (float)factor), validate_typeid); + write_command(set_typeid, offset, (uint8_t)(temperature * (float)factor), validate_typeid); return true; } diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index bae306d86..1ae77187d 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -62,32 +62,21 @@ std::string EMSdevice::brand_to_string() const { switch (brand_) { case EMSdevice::Brand::BOSCH: return read_flash_string(F("Bosch")); - break; case EMSdevice::Brand::JUNKERS: return read_flash_string(F("Junkers")); - break; case EMSdevice::Brand::BUDERUS: return read_flash_string(F("Buderus")); - break; case EMSdevice::Brand::NEFIT: return read_flash_string(F("Nefit")); - break; case EMSdevice::Brand::SIEGER: return read_flash_string(F("Sieger")); - break; case EMSdevice::Brand::WORCESTER: return read_flash_string(F("Worcester")); - break; case EMSdevice::Brand::IVT: return read_flash_string(F("IVT")); - break; - case EMSdevice::Brand::NO_BRAND: default: return read_flash_string(F("")); - break; } - - return std::string{}; } // returns the name of the MQTT topic to use for a specific device, without the base @@ -95,55 +84,30 @@ std::string EMSdevice::device_type_2_device_name(const uint8_t device_type) { switch (device_type) { case DeviceType::SYSTEM: return read_flash_string(F_(system)); - break; - case DeviceType::BOILER: return read_flash_string(F_(boiler)); - break; - case DeviceType::THERMOSTAT: return read_flash_string(F_(thermostat)); - break; - case DeviceType::HEATPUMP: return read_flash_string(F_(heatpump)); - break; - case DeviceType::SOLAR: return read_flash_string(F_(solar)); - break; - case DeviceType::CONNECT: return read_flash_string(F_(connect)); - break; - case DeviceType::MIXER: return read_flash_string(F_(mixer)); - break; - case DeviceType::DALLASSENSOR: return read_flash_string(F_(dallassensor)); - break; - case DeviceType::ANALOGSENSOR: return read_flash_string(F_(analogsensor)); - break; - case DeviceType::CONTROLLER: return read_flash_string(F_(controller)); - break; - case DeviceType::SWITCH: return read_flash_string(F_(switch)); - break; - case DeviceType::GATEWAY: return read_flash_string(F_(gateway)); - break; - default: return read_flash_string(F_(unknown)); - break; } } @@ -207,28 +171,20 @@ uint8_t EMSdevice::decode_brand(uint8_t value) { switch (value) { case 1: return EMSdevice::Brand::BOSCH; - break; case 2: return EMSdevice::Brand::JUNKERS; - break; case 3: return EMSdevice::Brand::BUDERUS; - break; case 4: return EMSdevice::Brand::NEFIT; - break; case 5: return EMSdevice::Brand::SIEGER; - break; case 11: return EMSdevice::Brand::WORCESTER; - break; case 13: return EMSdevice::Brand::IVT; - break; default: return EMSdevice::Brand::NO_BRAND; - break; } } @@ -579,7 +535,6 @@ void EMSdevice::publish_value(void * value_p) const { } break; } - case DeviceValueType::USHORT: Helpers::render_value(payload, *(uint16_t *)(value_p), divider, fahrenheit); break; @@ -603,11 +558,12 @@ void EMSdevice::publish_value(void * value_p) const { Helpers::render_value(payload, *(uint32_t *)(value_p), divider); break; case DeviceValueType::STRING: - default: if (Helpers::hasValue((char *)(value_p))) { strlcpy(payload, (char *)(value_p), sizeof(payload)); } break; + default: + break; } if (payload[0] != '\0') { diff --git a/src/helpers.cpp b/src/helpers.cpp index d89facaad..279b7ba11 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -587,12 +587,12 @@ bool Helpers::value2bool(const char * v, bool & value) { std::string bool_str = toLower(v); // convert to lower case - if ((bool_str == read_flash_string(F_(on))) || (bool_str == "1") or (bool_str == "true")) { + if ((bool_str == read_flash_string(F_(on))) || (bool_str == "1") || (bool_str == "true")) { value = true; return true; // is a bool } - if ((bool_str == read_flash_string(F_(off))) || (bool_str == "0") or (bool_str == "false")) { + if ((bool_str == read_flash_string(F_(off))) || (bool_str == "0") || (bool_str == "false")) { value = false; return true; // is a bool } diff --git a/src/mqtt.cpp b/src/mqtt.cpp index bfdd28407..c58f41540 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -1313,7 +1313,7 @@ void Mqtt::publish_ha_climate_config(uint8_t tag, bool has_roomtemp, bool remove // based on the device and tag, create the MQTT topic name (without the basename) // differs based on whether MQTT nested is enabled // tag = EMSdevice::DeviceValueTAG -const std::string Mqtt::tag_to_topic(uint8_t device_type, uint8_t tag) { +std::string Mqtt::tag_to_topic(uint8_t device_type, uint8_t tag) { // the system device is treated differently. The topic is 'heartbeat' and doesn't follow the usual convention if (device_type == EMSdevice::DeviceType::SYSTEM) { return EMSdevice::tag_to_mqtt(tag); diff --git a/src/mqtt.h b/src/mqtt.h index 712f65233..743870251 100644 --- a/src/mqtt.h +++ b/src/mqtt.h @@ -220,7 +220,7 @@ class Mqtt { return mqtt_messages_.empty(); } - static const std::string tag_to_topic(uint8_t device_type, uint8_t tag); + static std::string tag_to_topic(uint8_t device_type, uint8_t tag); struct QueuedMqttMessage { const uint32_t id_; diff --git a/src/system.cpp b/src/system.cpp index 9ac897566..336c3ba2c 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -1135,9 +1135,11 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp node["bus status"] = (F("connected, tx issues - try a different tx-mode")); break; case EMSESP::BUS_STATUS_CONNECTED: - default: node["bus status"] = (F("connected")); break; + default: + node["bus status"] = (F("unknown")); + break; } if (EMSESP::bus_status() != EMSESP::BUS_STATUS_OFFLINE) { @@ -1280,7 +1282,7 @@ bool System::command_restart(const char * value, const int8_t id) { return true; } -const std::string System::reset_reason(uint8_t cpu) { +std::string System::reset_reason(uint8_t cpu) const { #ifndef EMSESP_STANDALONE switch (rtc_get_reset_reason(cpu)) { case 1: diff --git a/src/system.h b/src/system.h index d87e6e737..970b77731 100644 --- a/src/system.h +++ b/src/system.h @@ -65,7 +65,7 @@ class System { static bool command_customizations(const char * value, const int8_t id, JsonObject & output); static bool command_commands(const char * value, const int8_t id, JsonObject & output); - const std::string reset_reason(uint8_t cpu); + std::string reset_reason(uint8_t cpu) const; void system_restart(); void format(uuid::console::Shell & shell); diff --git a/src/telegram.h b/src/telegram.h index 31e03167d..cf05e5076 100644 --- a/src/telegram.h +++ b/src/telegram.h @@ -270,7 +270,7 @@ class RxService : public EMSbus { } }; - const std::deque queue() const { + std::deque queue() const { return rx_telegrams_; } @@ -400,12 +400,12 @@ class TxService : public EMSbus { } }; - const std::deque queue() const { + std::deque queue() const { return tx_telegrams_; } bool tx_queue_empty() const { - return tx_telegrams_.size() == 0; + return tx_telegrams_.empty(); } #if defined(EMSESP_DEBUG) diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index f7de6d90d..3ade88792 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -49,7 +49,7 @@ void WebAPIService::webAPIService_get(AsyncWebServerRequest * request) { // POST /{device}[/{hc|id}][/{name}] void WebAPIService::webAPIService_post(AsyncWebServerRequest * request, JsonVariant & json) { // if no body then treat it as a secure GET - if (not json.is()) { + if (!json.is()) { webAPIService_get(request); return; } diff --git a/src/web/WebCustomizationService.cpp b/src/web/WebCustomizationService.cpp index aa3e5c2c7..7564de6e5 100644 --- a/src/web/WebCustomizationService.cpp +++ b/src/web/WebCustomizationService.cpp @@ -162,7 +162,7 @@ void WebCustomizationService::devices(AsyncWebServerRequest * request) { JsonObject root = response->getRoot(); JsonArray devices = root.createNestedArray("devices"); - for (auto & emsdevice : EMSESP::emsdevices) { + for (const auto & emsdevice : EMSESP::emsdevices) { if (emsdevice->has_entities()) { JsonObject obj = devices.createNestedObject(); obj["i"] = emsdevice->unique_id(); // a unique id diff --git a/src/web/WebDataService.cpp b/src/web/WebDataService.cpp index 7e8a34fde..7f331c9c5 100644 --- a/src/web/WebDataService.cpp +++ b/src/web/WebDataService.cpp @@ -76,7 +76,7 @@ void WebDataService::core_data(AsyncWebServerRequest * request) { // list is already sorted by device type // Ignore Contoller JsonArray devices = root.createNestedArray("devices"); - for (auto & emsdevice : EMSESP::emsdevices) { + for (const auto & emsdevice : EMSESP::emsdevices) { if (emsdevice && emsdevice->device_type() != EMSdevice::DeviceType::CONTROLLER) { JsonObject obj = devices.createNestedObject(); obj["i"] = emsdevice->unique_id(); // a unique id @@ -215,7 +215,7 @@ void WebDataService::write_value(AsyncWebServerRequest * request, JsonVariant & return_code = Command::call(device_type, cmd, Helpers::render_value(s, data.as(), 0), true, id, output); } else if (data.is()) { char s[10]; - return_code = Command::call(device_type, cmd, Helpers::render_value(s, (float)data.as(), 1), true, id, output); + return_code = Command::call(device_type, cmd, Helpers::render_value(s, data.as(), 1), true, id, output); } else if (data.is()) { return_code = Command::call(device_type, cmd, data.as() ? "true" : "false", true, id, output); } diff --git a/src/web/WebLogService.cpp b/src/web/WebLogService.cpp index 725719f1a..56c89070a 100644 --- a/src/web/WebLogService.cpp +++ b/src/web/WebLogService.cpp @@ -213,7 +213,7 @@ void WebLogService::fetchLog(AsyncWebServerRequest * request) { // sets the values like level after a POST void WebLogService::setValues(AsyncWebServerRequest * request, JsonVariant & json) { - if (not json.is()) { + if (!json.is()) { return; }