show sensor command commands

This commit is contained in:
MichaelDvP
2024-01-30 08:05:50 +01:00
parent 0f799d5922
commit de9c224a23
3 changed files with 16 additions and 18 deletions

View File

@@ -176,7 +176,7 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
String dat = output["api_data"];
output.clear();
input["data"] = dat.c_str();
data = input["data"];
data = input["data"];
}
}
}
@@ -439,7 +439,11 @@ void Command::erase_command(const uint8_t device_type, const char * cmd) {
// list all commands for a specific device, output as json
bool Command::list(const uint8_t device_type, JsonObject output) {
if (cmdfunctions_.empty()) {
// force add info and commands for those non-EMS devices
if (device_type == EMSdevice::DeviceType::TEMPERATURESENSOR || device_type == EMSdevice::DeviceType::ANALOGSENSOR) {
output[F_(info)] = Helpers::translated_word(FL_(info_cmd));
output[F_(commands)] = Helpers::translated_word(FL_(commands_cmd));
} else if (cmdfunctions_.empty()) {
output["message"] = "no commands available";
return false;
}
@@ -453,12 +457,6 @@ bool Command::list(const uint8_t device_type, JsonObject output) {
}
sorted_cmds.sort();
// force add info and commands for those non-EMS devices
if (device_type == EMSdevice::DeviceType::TEMPERATURESENSOR) {
output[F_(info)] = Helpers::translated_word(FL_(info_cmd));
output[F_(commands)] = Helpers::translated_word(FL_(commands_cmd));
}
for (const auto & cl : sorted_cmds) {
for (const auto & cf : cmdfunctions_) {
if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && cf.description_ && (cl == std::string(cf.cmd_))) {