From a33733484c12f679c9d22196be76f505cd9a854b Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Wed, 31 Jul 2024 09:58:16 +0200 Subject: [PATCH] always default to values (incl. allvalues), fix typo, --- src/command.cpp | 4 ++-- src/system.cpp | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index 4b667b51b..b41cfb3c6 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -103,9 +103,9 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec } if (command_p == nullptr) { // handle dead endpoints like api/system or api/boiler - // default to 'info' for SYSTEM, the other devices to 'values' for shortname version + // default to 'value' for all devices if (num_paths < (id_n > 0 ? 4 : 3)) { - command_p = device_type == EMSdevice::DeviceType::SYSTEM ? F_(info) : F_(values); + command_p = F_(values); } else { return json_message(CommandRet::NOT_FOUND, "missing or bad command", output); } diff --git a/src/system.cpp b/src/system.cpp index 222569341..865b26790 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -108,33 +108,38 @@ bool System::command_response(const char * value, const int8_t id, JsonObject ou return true; } -// output all the EMS devices and their values, plus the sensors and any custom entities -// not scheduler as these are records with no output data +// output all the devices and the values +// not system info bool System::command_allvalues(const char * value, const int8_t id, JsonObject output) { JsonDocument doc; JsonObject device_output; + // System Entities + // device_output = output["System"].to(); + // get_value_info(device_output, F_(values)); + + // EMS-Device Entities for (const auto & emsdevice : EMSESP::emsdevices) { std::string title = emsdevice->device_type_2_device_name_translated() + std::string(" ") + emsdevice->to_string(); device_output = output[title].to(); - emsdevice->generate_values(device_output, DeviceValueTAG::TAG_NONE, true, EMSdevice::OUTPUT_TARGET::API_VERBOSE); // use nested for id -1 and 0 + emsdevice->get_value_info(device_output, F_(values), DeviceValueTAG::TAG_NONE); } // Custom Entities device_output = output["Custom Entities"].to(); - EMSESP::webCustomEntityService.get_value_info(device_output, ""); + EMSESP::webCustomEntityService.get_value_info(device_output, F_(values)); // Scheduler device_output = output["Scheduler"].to(); - EMSESP::webSchedulerService.get_value_info(device_output, ""); + EMSESP::webSchedulerService.get_value_info(device_output, F_(values)); // Sensors device_output = output["Analog Sensors"].to(); - EMSESP::analogsensor_.get_value_info(device_output, "values"); + EMSESP::analogsensor_.get_value_info(device_output, F_(values)); device_output = output["Temperature Sensors"].to(); - EMSESP::temperaturesensor_.get_value_info(device_output, "values"); + EMSESP::temperaturesensor_.get_value_info(device_output, F_(values)); - return true; + return device_output.size() > 0; } // fetch device values @@ -1291,7 +1296,7 @@ bool System::get_value_info(JsonObject output, const char * cmd) { } // check for hardcoded "info"/"value" - if (!strcmp(cmd, F_(info)) || !strcmp(cmd, F_(value))) { + if (!strcmp(cmd, F_(info)) || !strcmp(cmd, F_(values))) { return command_info("", 0, output); }