diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 713245287..cbad0a163 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -538,6 +538,7 @@ bool EMSdevice::generate_values_json_web(JsonObject & json) { // For each value in the device create the json object pair and add it to given json // return false if empty +// this is used to create both the MQTT payloads and Console messages bool EMSdevice::generate_values_json(JsonObject & root, const uint8_t tag_filter, const bool verbose) { bool has_value = false; // to see if we've added a value. it's faster than doing a json.size() at the end uint8_t old_tag = 255; @@ -573,7 +574,8 @@ bool EMSdevice::generate_values_json(JsonObject & root, const uint8_t tag_filter has_value = true; } else { // see how to render the value depending on the setting - if (Mqtt::bool_format() == BOOL_FORMAT_ONOFF) { + // when in verbose mode (i.e. outout is Console) we always use on and off + if ((Mqtt::bool_format() == BOOL_FORMAT_ONOFF) || verbose) { // on or off as strings json[name] = *(uint8_t *)(dv.value_p) ? F_(on) : F_(off); has_value = true; diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 2d6b8099a..18babf65d 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -274,6 +274,7 @@ void EMSESP::show_ems(uuid::console::Shell & shell) { } // show EMS device values to the shell console +// this is the only time generate_values_json is called in verbose mode (set to true) void EMSESP::show_device_values(uuid::console::Shell & shell) { if (emsdevices.empty()) { shell.printfln(F("No EMS devices detected. Try using 'scan devices' from the ems menu.")); @@ -415,6 +416,7 @@ void EMSESP::reset_mqtt_ha() { } // create json doc for the devices values and add to MQTT publish queue +// generate_values_json is called without verbose mode (defaults to false) void EMSESP::publish_device_values(uint8_t device_type) { DynamicJsonDocument doc(EMSESP_JSON_SIZE_XLARGE_DYN); // use max size JsonObject json = doc.to(); @@ -441,7 +443,7 @@ void EMSESP::publish_device_values(uint8_t device_type) { } if ((device_type != DeviceType::THERMOSTAT) || (emsdevice->device_id() == EMSESP::actual_master_thermostat())) { - // for all other devices add the values to the json, without verbose mode + // for all other devices add the values to the json has_value |= emsdevice->generate_values_json(json, DeviceValueTAG::TAG_NONE); } } @@ -879,7 +881,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, std:: } // export all values to info command -// value and id are ignored +// value is ignored here bool EMSESP::command_info(uint8_t device_type, JsonObject & json, const int8_t id) { bool has_value = false; uint8_t tag = DeviceValueTAG::TAG_NONE;