From fa24a6878e0d2f521305c101fad2eb418c20a7c3 Mon Sep 17 00:00:00 2001 From: proddy Date: Tue, 23 Jul 2024 22:29:30 +0200 Subject: [PATCH] add values as a possible command --- src/command.cpp | 4 +++- src/web/WebCustomEntityService.cpp | 4 +++- src/web/WebSchedulerService.cpp | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index 1210c47e5..fda02bb98 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -510,10 +510,11 @@ std::string Command::tagged_cmd(const std::string & cmd, const uint8_t flag) { // list all commands for a specific device, output as json bool Command::list(const uint8_t device_type, JsonObject output) { - // force add info and commands for those non-EMS devices + // check of it a 'commands' command 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)); + output[F_(values)] = Helpers::translated_word(FL_(values_cmd)); } else if (cmdfunctions_.empty()) { output["message"] = "no commands available"; return false; @@ -555,6 +556,7 @@ void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbo if (!verbose && show_info) { sorted_cmds.push_back(F_(info)); sorted_cmds.push_back(F_(commands)); + sorted_cmds.push_back(F_(values)); } sorted_cmds.sort(); // sort them diff --git a/src/web/WebCustomEntityService.cpp b/src/web/WebCustomEntityService.cpp index 94f538861..f174d0885 100644 --- a/src/web/WebCustomEntityService.cpp +++ b/src/web/WebCustomEntityService.cpp @@ -256,10 +256,12 @@ void WebCustomEntityService::show_values(JsonObject output) { // process json output for info/commands and value_info bool WebCustomEntityService::get_value_info(JsonObject output, const char * cmd) { - // if it's commands... + // check of it a 'commands' command if (Helpers::toLower(cmd) == F_(commands)) { output[F_(info)] = Helpers::translated_word(FL_(info_cmd)); output[F_(commands)] = Helpers::translated_word(FL_(commands_cmd)); + output[F_(values)] = Helpers::translated_word(FL_(values_cmd)); + for (const auto & entity : *customEntityItems_) { if (entity.writeable) { output[entity.name] = "custom entity"; diff --git a/src/web/WebSchedulerService.cpp b/src/web/WebSchedulerService.cpp index bcc77eff8..52b44c5fa 100644 --- a/src/web/WebSchedulerService.cpp +++ b/src/web/WebSchedulerService.cpp @@ -136,6 +136,7 @@ bool WebSchedulerService::get_value_info(JsonObject output, const char * cmd) { if (Helpers::toLower(cmd) == F_(commands)) { output[F_(info)] = Helpers::translated_word(FL_(info_cmd)); output[F_(commands)] = Helpers::translated_word(FL_(commands_cmd)); + output[F_(values)] = Helpers::translated_word(FL_(values_cmd)); for (const ScheduleItem & scheduleItem : *scheduleItems_) { if (!scheduleItem.name.empty()) {