always default to values (incl. allvalues), fix typo,

This commit is contained in:
MichaelDvP
2024-07-31 09:58:16 +02:00
parent 95f0478fa7
commit a33733484c
2 changed files with 16 additions and 11 deletions

View File

@@ -103,9 +103,9 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
} }
if (command_p == nullptr) { if (command_p == nullptr) {
// handle dead endpoints like api/system or api/boiler // 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)) { if (num_paths < (id_n > 0 ? 4 : 3)) {
command_p = device_type == EMSdevice::DeviceType::SYSTEM ? F_(info) : F_(values); command_p = F_(values);
} else { } else {
return json_message(CommandRet::NOT_FOUND, "missing or bad command", output); return json_message(CommandRet::NOT_FOUND, "missing or bad command", output);
} }

View File

@@ -108,33 +108,38 @@ bool System::command_response(const char * value, const int8_t id, JsonObject ou
return true; return true;
} }
// output all the EMS devices and their values, plus the sensors and any custom entities // output all the devices and the values
// not scheduler as these are records with no output data // not system info
bool System::command_allvalues(const char * value, const int8_t id, JsonObject output) { bool System::command_allvalues(const char * value, const int8_t id, JsonObject output) {
JsonDocument doc; JsonDocument doc;
JsonObject device_output; JsonObject device_output;
// System Entities
// device_output = output["System"].to<JsonObject>();
// get_value_info(device_output, F_(values));
// EMS-Device Entities
for (const auto & emsdevice : EMSESP::emsdevices) { for (const auto & emsdevice : EMSESP::emsdevices) {
std::string title = emsdevice->device_type_2_device_name_translated() + std::string(" ") + emsdevice->to_string(); std::string title = emsdevice->device_type_2_device_name_translated() + std::string(" ") + emsdevice->to_string();
device_output = output[title].to<JsonObject>(); device_output = output[title].to<JsonObject>();
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 // Custom Entities
device_output = output["Custom Entities"].to<JsonObject>(); device_output = output["Custom Entities"].to<JsonObject>();
EMSESP::webCustomEntityService.get_value_info(device_output, ""); EMSESP::webCustomEntityService.get_value_info(device_output, F_(values));
// Scheduler // Scheduler
device_output = output["Scheduler"].to<JsonObject>(); device_output = output["Scheduler"].to<JsonObject>();
EMSESP::webSchedulerService.get_value_info(device_output, ""); EMSESP::webSchedulerService.get_value_info(device_output, F_(values));
// Sensors // Sensors
device_output = output["Analog Sensors"].to<JsonObject>(); device_output = output["Analog Sensors"].to<JsonObject>();
EMSESP::analogsensor_.get_value_info(device_output, "values"); EMSESP::analogsensor_.get_value_info(device_output, F_(values));
device_output = output["Temperature Sensors"].to<JsonObject>(); device_output = output["Temperature Sensors"].to<JsonObject>();
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 // fetch device values
@@ -1291,7 +1296,7 @@ bool System::get_value_info(JsonObject output, const char * cmd) {
} }
// check for hardcoded "info"/"value" // 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); return command_info("", 0, output);
} }