diff --git a/interface/package-lock.json b/interface/package-lock.json index f6a0e0767..79d2b99bc 100644 --- a/interface/package-lock.json +++ b/interface/package-lock.json @@ -16,7 +16,7 @@ "@table-library/react-table-library": "4.0.18", "@types/lodash": "^4.14.184", "@types/node": "^18.7.16", - "@types/react": "^18.0.18", + "@types/react": "^18.0.19", "@types/react-dom": "^18.0.6", "@types/react-router-dom": "^5.3.3", "async-validator": "^4.2.5", @@ -4048,9 +4048,9 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" }, "node_modules/@types/react": { - "version": "18.0.18", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.18.tgz", - "integrity": "sha512-6hI08umYs6NaiHFEEGioXnxJ+oEhY3eRz8VCUaudZmGdtvPviCJB8mgaMxaDWAdPSYd4eFavrPk2QIolwbLYrg==", + "version": "18.0.19", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.19.tgz", + "integrity": "sha512-BDc3Q+4Q3zsn7k9xZrKfjWyJsSlEDMs38gD1qp2eDazLCdcPqAT+vq1ND+Z8AGel/UiwzNUk8ptpywgNQcJ1MQ==", "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -20236,9 +20236,9 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" }, "@types/react": { - "version": "18.0.18", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.18.tgz", - "integrity": "sha512-6hI08umYs6NaiHFEEGioXnxJ+oEhY3eRz8VCUaudZmGdtvPviCJB8mgaMxaDWAdPSYd4eFavrPk2QIolwbLYrg==", + "version": "18.0.19", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.19.tgz", + "integrity": "sha512-BDc3Q+4Q3zsn7k9xZrKfjWyJsSlEDMs38gD1qp2eDazLCdcPqAT+vq1ND+Z8AGel/UiwzNUk8ptpywgNQcJ1MQ==", "requires": { "@types/prop-types": "*", "@types/scheduler": "*", diff --git a/interface/package.json b/interface/package.json index 748fdbc76..b77386526 100644 --- a/interface/package.json +++ b/interface/package.json @@ -12,7 +12,7 @@ "@table-library/react-table-library": "4.0.18", "@types/lodash": "^4.14.184", "@types/node": "^18.7.16", - "@types/react": "^18.0.18", + "@types/react": "^18.0.19", "@types/react-dom": "^18.0.6", "@types/react-router-dom": "^5.3.3", "async-validator": "^4.2.5", diff --git a/src/analogsensor.cpp b/src/analogsensor.cpp index 8ac30c9db..826f370f6 100644 --- a/src/analogsensor.cpp +++ b/src/analogsensor.cpp @@ -37,18 +37,18 @@ void AnalogSensor::start() { EMSdevice::DeviceType::ANALOGSENSOR, F_(info), [&](const char * value, const int8_t id, JsonObject & output) { return command_info(value, id, output); }, - uuid::read_flash_string(F_(info_cmd))); + F_(info_cmd)); Command::add( EMSdevice::DeviceType::ANALOGSENSOR, F_(setvalue), [&](const char * value, const int8_t id) { return command_setvalue(value, id); }, - "set io value", // TODO this needs translating + F("set io value"), // TODO this needs translating CommandFlag::ADMIN_ONLY); Command::add( EMSdevice::DeviceType::ANALOGSENSOR, F_(commands), [&](const char * value, const int8_t id, JsonObject & output) { return command_commands(value, id, output); }, - uuid::read_flash_string(F_(commands_cmd))); + F_(commands_cmd)); Mqtt::subscribe(EMSdevice::DeviceType::ANALOGSENSOR, "analogsensor/#", nullptr); // use empty function callback } diff --git a/src/command.cpp b/src/command.cpp index 6b2a8291f..cae119bec 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -264,15 +264,15 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * if ((value == nullptr) || (strlen(value) == 0)) { if (EMSESP::system_.readonly_mode()) { - LOG_INFO(F("[readonly] Calling command '%s/%s' (%s)"), dname.c_str(), cmd, cf->description_.c_str()); + LOG_INFO(F("[readonly] Calling command '%s/%s' (%s)"), dname.c_str(), cmd, read_flash_string(cf->description_).c_str()); } else { - LOG_DEBUG(F("Calling command '%s/%s' (%s)"), dname.c_str(), cmd, cf->description_.c_str()); + LOG_DEBUG(F("Calling command '%s/%s' (%s)"), dname.c_str(), cmd, read_flash_string(cf->description_).c_str()); } } else { if (EMSESP::system_.readonly_mode()) { - LOG_INFO(F("[readonly] Calling command '%s/%s' (%s) with value %s"), dname.c_str(), cmd, cf->description_.c_str(), value); + LOG_INFO(F("[readonly] Calling command '%s/%s' (%s) with value %s"), dname.c_str(), cmd, read_flash_string(cf->description_).c_str(), value); } else { - LOG_DEBUG(F("Calling command '%s/%s' (%s) with value %s"), dname.c_str(), cmd, cf->description_.c_str(), value); + LOG_DEBUG(F("Calling command '%s/%s' (%s) with value %s"), dname.c_str(), cmd, read_flash_string(cf->description_).c_str(), value); } } @@ -299,14 +299,14 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * } // add a command to the list, which does not return json -void Command::add(const uint8_t device_type, const __FlashStringHelper * cmd, const cmd_function_p cb, const std::string & description, uint8_t flags) { +void Command::add(const uint8_t device_type, const __FlashStringHelper * cmd, const cmd_function_p cb, const __FlashStringHelper * description, uint8_t flags) { // if the command already exists for that device type don't add it if (find_command(device_type, read_flash_string(cmd).c_str()) != nullptr) { return; } // if the description is empty, it's hidden which means it will not show up in Web API or Console as an available command - if (description.empty()) { + if (!description) { flags |= CommandFlag::HIDDEN; } @@ -314,7 +314,7 @@ void Command::add(const uint8_t device_type, const __FlashStringHelper * cmd, co } // add a command to the list, which does return a json object as output -void Command::add(const uint8_t device_type, const __FlashStringHelper * cmd, const cmd_json_function_p cb, const std::string & description, uint8_t flags) { +void Command::add(const uint8_t device_type, const __FlashStringHelper * cmd, const cmd_json_function_p cb, const __FlashStringHelper * description, uint8_t flags) { // if the command already exists for that device type don't add it if (find_command(device_type, read_flash_string(cmd).c_str()) != nullptr) { return; @@ -364,7 +364,7 @@ bool Command::list(const uint8_t device_type, JsonObject & output) { for (const auto & cl : sorted_cmds) { for (const auto & cf : cmdfunctions_) { - if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && !cf.description_.empty() && (cl == read_flash_string(cf.cmd_))) { + if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && cf.description_ && (cl == read_flash_string(cf.cmd_))) { output[cl] = cf.description_; } } @@ -404,7 +404,7 @@ void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbo 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_.empty() && (cl == read_flash_string(cf.cmd_))) { + if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && cf.description_ && (cl == read_flash_string(cf.cmd_))) { uint8_t i = cl.length(); shell.print(" "); if (cf.has_flags(MQTT_SUB_FLAG_HC)) { @@ -424,7 +424,7 @@ void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbo shell.print(EMSdevice::tag_to_string(DeviceValueTAG::TAG_DEVICE_DATA_WW)); shell.print(' '); } - shell.print(cf.description_.c_str()); + shell.print(read_flash_string(cf.description_).c_str()); if (!cf.has_flags(CommandFlag::ADMIN_ONLY)) { shell.print(' '); shell.print(COLOR_BRIGHT_RED); diff --git a/src/command.h b/src/command.h index 87a55d472..e12eab87a 100644 --- a/src/command.h +++ b/src/command.h @@ -59,14 +59,14 @@ class Command { const __FlashStringHelper * cmd_; const cmd_function_p cmdfunction_; const cmd_json_function_p cmdfunction_json_; - const std::string description_; + const __FlashStringHelper * description_; CmdFunction(const uint8_t device_type, const uint8_t flags, const __FlashStringHelper * cmd, const cmd_function_p cmdfunction, const cmd_json_function_p cmdfunction_json, - const std::string & description) + const __FlashStringHelper * description) : device_type_(device_type) , flags_(flags) , cmd_(cmd) @@ -102,14 +102,14 @@ class Command { static void add(const uint8_t device_type, const __FlashStringHelper * cmd, const cmd_function_p cb, - const std::string & description, + const __FlashStringHelper * description, uint8_t flags = CommandFlag::MQTT_SUB_FLAG_DEFAULT); // callback function taking value, id and a json object for its output static void add(const uint8_t device_type, const __FlashStringHelper * cmd, const cmd_json_function_p cb, - const std::string & description, + const __FlashStringHelper * description, uint8_t flags = CommandFlag::MQTT_SUB_FLAG_DEFAULT); static void show_all(uuid::console::Shell & shell); diff --git a/src/dallassensor.cpp b/src/dallassensor.cpp index 1a66688b8..030ad5474 100644 --- a/src/dallassensor.cpp +++ b/src/dallassensor.cpp @@ -50,12 +50,12 @@ void DallasSensor::start() { EMSdevice::DeviceType::DALLASSENSOR, F_(info), [&](const char * value, const int8_t id, JsonObject & output) { return command_info(value, id, output); }, - uuid::read_flash_string(F_(info_cmd))); + F_(info_cmd)); Command::add( EMSdevice::DeviceType::DALLASSENSOR, F_(commands), [&](const char * value, const int8_t id, JsonObject & output) { return command_commands(value, id, output); }, - uuid::read_flash_string(F_(commands_cmd))); + F_(commands_cmd)); Mqtt::subscribe(EMSdevice::DeviceType::DALLASSENSOR, "dallasssensor/#", nullptr); // use empty function callback } diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index a376e9bce..c30fbee39 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -453,17 +453,6 @@ void EMSdevice::add_device_value(uint8_t tag, shortname = entity_id.substr(2); } - /* - Serial.print(COLOR_BRIGHT_GREEN); - Serial.print(" entity name="); - Serial.print(entity_id.c_str()); - Serial.print(" ,matched name="); - Serial.print(matched_entity.c_str()); - Serial.print(" ,matched pos="); - Serial.println(custom_name_pos); - Serial.print(COLOR_RESET); - */ - // we found the device entity if (shortname == entity) { // get Mask @@ -471,11 +460,6 @@ void EMSdevice::add_device_value(uint8_t tag, state = mask << 4; // set state high bits to flag, turn off active and ha flags // see if there is a custom name in the entity string if (has_custom_name) { - /* - Serial.print(COLOR_BRIGHT_MAGENTA); - Serial.println(entity_id.substr(custom_name_pos + 1).c_str()); - Serial.print(COLOR_RESET); - */ custom_fullname = entity_id.substr(custom_name_pos + 1); } break; @@ -505,8 +489,8 @@ void EMSdevice::add_device_value(uint8_t tag, } // add the command to our library - // cmd is the short_name and the description is the fullname - Command::add(device_type_, short_name, f, Helpers::translated_word(fullname), flags); + // cmd is the short_name and the description is the fullname (not the custom fullname) + Command::add(device_type_, short_name, f, Helpers::translated_fword(fullname), flags); } // single list of options diff --git a/src/emsesp.cpp b/src/emsesp.cpp index e095eeb4b..5d5ced4fc 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -1052,25 +1052,25 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const [device_type](const char * value, const int8_t id, JsonObject & output) { return command_info(device_type, output, id, EMSdevice::OUTPUT_TARGET::API_VERBOSE); }, - uuid::read_flash_string(F_(info_cmd))); + F_(info_cmd)); Command::add( device_type, F("values"), [device_type](const char * value, const int8_t id, JsonObject & output) { return command_info(device_type, output, id, EMSdevice::OUTPUT_TARGET::API_SHORTNAMES); // HIDDEN command showing short names, used in e.g. /api/boiler }, - "", + nullptr, CommandFlag::HIDDEN); // this command is hidden Command::add( device_type, F_(commands), [device_type](const char * value, const int8_t id, JsonObject & output) { return command_commands(device_type, output, id); }, - uuid::read_flash_string(F_(commands_cmd))); + F_(commands_cmd)); Command::add( device_type, F_(entities), [device_type](const char * value, const int8_t id, JsonObject & output) { return command_entities(device_type, output, id); }, - uuid::read_flash_string(F_(entities_cmd))); + F_(entities_cmd)); // MQTT subscribe to the device e.g. "ems-esp/boiler/#" Mqtt::subscribe(device_type, EMSdevice::device_type_2_device_name(device_type) + "/#", nullptr); diff --git a/src/system.cpp b/src/system.cpp index 18cedfc1a..e1d65de13 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -292,7 +292,7 @@ void System::syslog_init() { // register the command // TODO translate this - Command::add(EMSdevice::DeviceType::SYSTEM, F_(syslog), System::command_syslog_level, "change the syslog level", CommandFlag::ADMIN_ONLY); + Command::add(EMSdevice::DeviceType::SYSTEM, F_(syslog), System::command_syslog_level, F("change the syslog level"), CommandFlag::ADMIN_ONLY); } else if (was_enabled) { // in case service is still running, this flushes the queue @@ -698,24 +698,24 @@ void System::commands_init() { // Command::add(EMSdevice::DeviceType::SYSTEM, F_(pin), System::command_pin, F("set a GPIO on/off"), CommandFlag::ADMIN_ONLY); // TODO these should be translated too - Command::add(EMSdevice::DeviceType::SYSTEM, F_(send), System::command_send, "send a telegram", CommandFlag::ADMIN_ONLY); - Command::add(EMSdevice::DeviceType::SYSTEM, F_(fetch), System::command_fetch, "refresh all EMS values", CommandFlag::ADMIN_ONLY); - Command::add(EMSdevice::DeviceType::SYSTEM, F_(restart), System::command_restart, "restart EMS-ESP", CommandFlag::ADMIN_ONLY); - Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, "watch incoming telegrams"); + Command::add(EMSdevice::DeviceType::SYSTEM, F_(send), System::command_send, F("send a telegram"), CommandFlag::ADMIN_ONLY); + Command::add(EMSdevice::DeviceType::SYSTEM, F_(fetch), System::command_fetch, F("refresh all EMS values"), CommandFlag::ADMIN_ONLY); + Command::add(EMSdevice::DeviceType::SYSTEM, F_(restart), System::command_restart, F("restart EMS-ESP"), CommandFlag::ADMIN_ONLY); + Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, F("watch incoming telegrams")); // register syslog command in syslog init // Command::add(EMSdevice::DeviceType::SYSTEM, F_(syslog), System::command_syslog_level, F("set syslog level"), CommandFlag::ADMIN_ONLY); if (Mqtt::enabled()) { - Command::add(EMSdevice::DeviceType::SYSTEM, F_(publish), System::command_publish, "force a MQTT publish"); + Command::add(EMSdevice::DeviceType::SYSTEM, F_(publish), System::command_publish, F("force a MQTT publish")); } // these commands will return data in JSON format - Command::add(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info, "show system status"); - Command::add(EMSdevice::DeviceType::SYSTEM, F_(commands), System::command_commands, "fetch system commands"); + Command::add(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info, F("show system status")); + Command::add(EMSdevice::DeviceType::SYSTEM, F_(commands), System::command_commands, F("fetch system commands")); #if defined(EMSESP_DEBUG) - Command::add(EMSdevice::DeviceType::SYSTEM, F("test"), System::command_test, "run a specific test"); + Command::add(EMSdevice::DeviceType::SYSTEM, F("test"), System::command_test, F("run a specific test")); #endif // MQTT subscribe "ems-esp/system/#"