mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
siwtch info with list - #176
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user