From 18d32de483be19c9555de3e5d2744029eab8b84d Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 13 Jul 2023 18:23:04 +0200 Subject: [PATCH] fix custom entity value info --- src/web/WebEntityService.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/web/WebEntityService.cpp b/src/web/WebEntityService.cpp index 81a188c62..8a01325ff 100644 --- a/src/web/WebEntityService.cpp +++ b/src/web/WebEntityService.cpp @@ -115,7 +115,7 @@ bool WebEntityService::command_setvalue(const char * value, const std::string na strlcpy(telegram, value, sizeof(telegram)); uint8_t data[EMS_MAX_TELEGRAM_LENGTH]; uint8_t count = 0; - char * p = strtok(telegram, " ,"); // delimiter + char * p = strtok(telegram, " ,"); // delimiter while (p != nullptr) { data[count++] = (uint8_t)strtol(p, 0, 16); p = strtok(nullptr, " ,"); @@ -244,12 +244,22 @@ bool WebEntityService::get_value_info(JsonObject & output, const char * cmd) { } for (const auto & entity : *entityItems) { if (Helpers::toLower(entity.name) == Helpers::toLower(command_s)) { - output["name"] = entity.name; - output["uom"] = EMSdevice::uom_to_string(entity.uom); - output["type"] = entity.value_type == DeviceValueType::BOOL ? "boolean" : F_(number); + output["name"] = entity.name; + if (entity.uom > 0) { + output["uom"] = EMSdevice::uom_to_string(entity.uom); + } + output["type"] = entity.value_type == DeviceValueType::BOOL ? "boolean" : entity.value_type == DeviceValueType::STRING ? "string" : F_(number); output["readable"] = true; output["writeable"] = entity.writeable; output["visible"] = true; + output["device_id"] = entity.device_id; + output["type_id"] = entity.type_id; + output["offset"] = entity.offset; + if (entity.value_type != DeviceValueType::BOOL && entity.value_type != DeviceValueType::STRING) { + output["factor"] = entity.factor; + } else if (entity.value_type == DeviceValueType::STRING) { + output["bytes"] = (uint8_t)entity.factor; + } render_value(output, entity, true); if (attribute_s) { if (output.containsKey(attribute_s)) {