From 3d7378a1a8537d822f2d9d7592fc546183f5a80a Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 8 Jul 2024 18:02:14 +0200 Subject: [PATCH] cmd info shows right type (number/enum), no value --- src/emsdevice.cpp | 13 +++++++++---- src/web/WebSchedulerService.cpp | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 1b527f988..edef31030 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -1548,12 +1548,16 @@ bool EMSdevice::get_value_info(JsonObject output, const char * cmd, const int8_t break; case DeviceValueType::CMD: - json[type] = F_(command); if (dv.options_size > 1) { + json[type] = F_(enum); JsonArray enum_ = json[F_(enum)].to(); for (uint8_t i = 0; i < dv.options_size; i++) { enum_.add(Helpers::translated_word(dv.options[i])); } + } else if (dv.uom != DeviceValueUOM::NONE) { + json[type] = F_(number); + } else { + json[type] = F_(command); } break; @@ -1581,10 +1585,11 @@ bool EMSdevice::get_value_info(JsonObject output, const char * cmd, const int8_t json["writeable"] = dv.has_cmd && !dv.has_state(DeviceValueState::DV_READONLY); json["visible"] = !dv.has_state(DeviceValueState::DV_WEB_EXCLUDE); + // commented out, leads to issues if type is set to number // if there is no value, mention it - if (!json.containsKey(value)) { - json[value] = "not set"; - } + // if (!json.containsKey(value)) { + // json[value] = "not set"; + // } // if we're filtering on an attribute, go find it if (attribute_s) { diff --git a/src/web/WebSchedulerService.cpp b/src/web/WebSchedulerService.cpp index fb03487cb..45a2a0e6c 100644 --- a/src/web/WebSchedulerService.cpp +++ b/src/web/WebSchedulerService.cpp @@ -161,7 +161,7 @@ bool WebSchedulerService::get_value_info(JsonObject output, const char * cmd) { } } - return (output.size() > 0); + return true; } char command_s[COMMAND_MAX_LENGTH];