mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
always default to values (incl. allvalues), fix typo,
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<JsonObject>();
|
||||
// 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<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
|
||||
device_output = output["Custom Entities"].to<JsonObject>();
|
||||
EMSESP::webCustomEntityService.get_value_info(device_output, "");
|
||||
EMSESP::webCustomEntityService.get_value_info(device_output, F_(values));
|
||||
|
||||
// Scheduler
|
||||
device_output = output["Scheduler"].to<JsonObject>();
|
||||
EMSESP::webSchedulerService.get_value_info(device_output, "");
|
||||
EMSESP::webSchedulerService.get_value_info(device_output, F_(values));
|
||||
|
||||
// Sensors
|
||||
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>();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user