From 049be2484e8b873918d9ba4bbf6a2c584e357a63 Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 29 Jul 2021 16:53:06 +0200 Subject: [PATCH] don't show dallas in system/info as its not an ems device --- src/system.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/system.cpp b/src/system.cpp index 4f6eba475..bb1ab41ff 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -614,9 +614,9 @@ void System::commands_init() { Command::add(EMSdevice::DeviceType::SYSTEM, F_(publish), System::command_publish, F("force a MQTT publish"), CommandFlag::ADMIN_ONLY); Command::add(EMSdevice::DeviceType::SYSTEM, F_(fetch), System::command_fetch, F("refresh all EMS values"), CommandFlag::ADMIN_ONLY); Command::add(EMSdevice::DeviceType::SYSTEM, F_(restart), System::command_restart, F("restarts EMS-ESP"), CommandFlag::ADMIN_ONLY); - Command::add_returns_json(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info, F("system status")); - Command::add_returns_json(EMSdevice::DeviceType::SYSTEM, F_(settings), System::command_settings, F("list system settings")); - Command::add_returns_json(EMSdevice::DeviceType::SYSTEM, F_(commands), System::command_commands, F("list system commands")); + Command::add_json(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info, F("system status")); + Command::add_json(EMSdevice::DeviceType::SYSTEM, F_(settings), System::command_settings, F("list system settings")); + Command::add_json(EMSdevice::DeviceType::SYSTEM, F_(commands), System::command_commands, F("list system commands")); #if defined(EMSESP_DEBUG) Command::add(EMSdevice::DeviceType::SYSTEM, F("test"), System::command_test, F("run tests")); #endif @@ -775,7 +775,7 @@ bool System::command_commands(const char * value, const int8_t id, JsonObject & } // export all settings to JSON text -// e.g. http://ems-esp/api?device=system&cmd=settings +// http://ems-esp/api/system/settings // value and id are ignored bool System::command_settings(const char * value, const int8_t id, JsonObject & json) { JsonObject node; @@ -878,8 +878,8 @@ bool System::command_settings(const char * value, const int8_t id, JsonObject & return true; } -// export status information including some basic settings -// e.g. http://ems-esp/api?device=system&cmd=info +// export status information including the device information +// http://ems-esp/api/system/info bool System::command_info(const char * value, const int8_t id, JsonObject & json) { JsonObject node; @@ -934,12 +934,12 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & json #endif } - JsonArray devices2 = json.createNestedArray("Devices"); - + // show EMS devices + JsonArray devices = json.createNestedArray("Devices"); for (const auto & device_class : EMSFactory::device_handlers()) { for (const auto & emsdevice : EMSESP::emsdevices) { if ((emsdevice) && (emsdevice->device_type() == device_class.first)) { - JsonObject obj = devices2.createNestedObject(); + JsonObject obj = devices.createNestedObject(); obj["type"] = emsdevice->device_type_name(); obj["name"] = emsdevice->to_string(); char result[200]; @@ -947,11 +947,6 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & json } } } - if (EMSESP::sensor_devices().size()) { - JsonObject obj = devices2.createNestedObject(); - obj["type"] = F_(Dallassensor); - obj["name"] = F_(Dallassensor); - } return true; }