From 4f42ae7efcb7ff5a85ae5c29c1b80494fb415202 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Fri, 2 Sep 2022 14:16:24 +0200 Subject: [PATCH] console show handle enum/bool like web --- src/emsdevice.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 9f1f2eb69..c322d2618 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -1238,15 +1238,15 @@ bool EMSdevice::generate_values(JsonObject & output, const uint8_t tag_filter, c if (Mqtt::ha_enabled() && (output_target == OUTPUT_TARGET::MQTT)) { char s[7]; json[name] = Helpers::render_boolean(s, value_b); // for HA always render as string - } else { - if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) { - json[name] = value_b; - } else if (EMSESP::system_.bool_format() == BOOL_FORMAT_10) { - json[name] = value_b ? 1 : 0; - } else { - char s[7]; - json[name] = Helpers::render_boolean(s, value_b); - } + } else if (output_target == OUTPUT_TARGET::CONSOLE) { + char s[7]; + json[name] = Helpers::render_boolean(s, value_b, true); // console use web settings + } else if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) { + json[name] = value_b; + } else if (EMSESP::system_.bool_format() == BOOL_FORMAT_10) { + json[name] = value_b ? 1 : 0; + char s[7]; + json[name] = Helpers::render_boolean(s, value_b); } } @@ -1257,8 +1257,8 @@ bool EMSdevice::generate_values(JsonObject & output, const uint8_t tag_filter, c // handle ENUMs else if ((dv.type == DeviceValueType::ENUM) && (*(uint8_t *)(dv.value_p) < dv.options_size)) { - // check for numeric enum-format - if (EMSESP::system_.enum_format() == ENUM_FORMAT_INDEX) { + // check for numeric enum-format, console use text format + if (EMSESP::system_.enum_format() == ENUM_FORMAT_INDEX && output_target != OUTPUT_TARGET::CONSOLE) { json[name] = (uint8_t)(*(uint8_t *)(dv.value_p)); } else { json[name] = Helpers::translated_word(dv.options[*(uint8_t *)(dv.value_p)]);