diff --git a/src/emsdevice.h b/src/emsdevice.h index 66a046816..4adfa82e9 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -248,7 +248,7 @@ class EMSdevice { const std::string get_value_uom(const char * key); bool get_value_info(JsonObject & root, const char * cmd, const int8_t id); - enum OUTPUT_TARGET : uint8_t { API_VERBOSE, API, MQTT }; + enum OUTPUT_TARGET : uint8_t { API_VERBOSE, API_SHORT, MQTT }; bool generate_values_json(JsonObject & output, const uint8_t tag_filter, const bool nested, const uint8_t output_target); void generate_values_json_web(JsonObject & output); diff --git a/src/emsesp.cpp b/src/emsesp.cpp index ad061dc29..ea9ee3841 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -999,7 +999,9 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, std:: Command::add( device_type, F("list"), - [device_type](const char * value, const int8_t id, JsonObject & output) { return command_info(device_type, output, id, EMSdevice::OUTPUT_TARGET::API); }, + [device_type](const char * value, const int8_t id, JsonObject & output) { + return command_info(device_type, output, id, EMSdevice::OUTPUT_TARGET::API_SHORT); // HIDDEN command showing short names, used in e.g. /api/boiler + }, nullptr, CommandFlag::HIDDEN); // this command is hidden Command::add( @@ -1042,9 +1044,7 @@ bool EMSESP::command_commands(uint8_t device_type, JsonObject & output, const in return Command::list(device_type, output); } -// export all values -// value is ignored here -// info command always shows in verbose mode, so full names are displayed +// export all values for a specific device bool EMSESP::command_info(uint8_t device_type, JsonObject & output, const int8_t id, const uint8_t output_target) { bool has_value = false; uint8_t tag; @@ -1061,7 +1061,7 @@ bool EMSESP::command_info(uint8_t device_type, JsonObject & output, const int8_t for (const auto & emsdevice : emsdevices) { if (emsdevice && (emsdevice->device_type() == device_type) && ((device_type != DeviceType::THERMOSTAT) || (emsdevice->device_id() == EMSESP::actual_master_thermostat()))) { - has_value |= emsdevice->generate_values_json(output, tag, (id < 1), output_target); // nested for id -1 and 0 + has_value |= emsdevice->generate_values_json(output, tag, (id < 1), output_target); // use nested for id -1 and 0 } } diff --git a/src/test/test.cpp b/src/test/test.cpp index dc44b9ccc..1344df5c9 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -495,13 +495,18 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) { return; */ - /* AsyncWebServerRequest request2; request2.method(HTTP_GET); - request2.url("/api/thermostat/mode/auto"); // check if defaults to info + // request2.url("/api/thermostat/seltemp"); + // EMSESP::webAPIService.webAPIService_get(&request2); + // return; + + /* + request2.url("/api/thermostat/mode/auto"); EMSESP::webAPIService.webAPIService_get(&request2); return; + */ request2.url("/api/thermostat"); // check if defaults to info EMSESP::webAPIService.webAPIService_get(&request2); @@ -509,10 +514,11 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) { EMSESP::webAPIService.webAPIService_get(&request2); request2.url("/api/thermostat/list"); EMSESP::webAPIService.webAPIService_get(&request2); + return; + request2.url("/api/thermostat/mode"); EMSESP::webAPIService.webAPIService_get(&request2); return; - */ /* AsyncWebServerRequest request2; diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index aa5b59406..88a1cd0ca 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -63,9 +63,9 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) { bool authenticated = false; if (method == HTTP_GET) { - // special case if there is no command, then default to 'info' + // special case if there is no command, then default to 'list' which is like info but showing short names if (!input.size()) { - input["cmd"] = "info"; + input["cmd"] = "list"; } } else { // if its a POST then check authentication