From 8d7ac5b7128470371a4eaf94ed939dea4d20c4e1 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Wed, 9 Sep 2020 11:01:31 +0200 Subject: [PATCH] Mixing MM100 fix pump/status, MM10 add valveStatus (-100%..100%) --- src/devices/mixing.cpp | 45 ++++++++++++++++++++---------------------- src/devices/mixing.h | 4 ++-- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/devices/mixing.cpp b/src/devices/mixing.cpp index 08f056b24..209a0ef5f 100644 --- a/src/devices/mixing.cpp +++ b/src/devices/mixing.cpp @@ -68,14 +68,14 @@ void Mixing::device_info_web(JsonArray & root) { if (type_ == Type::WWC) { render_value_json(root, "", F("Warm Water Circuit"), hc_, nullptr); render_value_json(root, "", F("Current warm water temperature"), flowTemp_, F_(degrees), 10); - render_value_json(root, "", F("Current pump status"), pumpMod_, nullptr); + render_value_json(root, "", F("Current pump status"), pump_, nullptr); render_value_json(root, "", F("Current temperature status"), status_, nullptr); } else { render_value_json(root, "", F("Heating Circuit"), hc_, nullptr); render_value_json(root, "", F("Current flow temperature"), flowTemp_, F_(degrees), 10); render_value_json(root, "", F("Setpoint flow temperature"), flowSetTemp_, F_(degrees)); - render_value_json(root, "", F("Current pump modulation"), pumpMod_, F_(percent)); - render_value_json(root, "", F("Current valve status"), status_, nullptr); + render_value_json(root, "", F("Current pump status"), pump_, nullptr, EMS_VALUE_BOOL); + render_value_json(root, "", F("Current valve status"), status_, F_(percent)); } } @@ -103,14 +103,14 @@ void Mixing::show_values(uuid::console::Shell & shell) { if (type_ == Type::WWC) { print_value(shell, 2, F("Warm Water Circuit"), hc_, nullptr); print_value(shell, 4, F("Current warm water temperature"), flowTemp_, F_(degrees), 10); - print_value(shell, 4, F("Current pump status"), pumpMod_, nullptr); + print_value(shell, 4, F("Current pump status"), pump_, nullptr); print_value(shell, 4, F("Current temperature status"), status_, nullptr); } else { print_value(shell, 2, F("Heating Circuit"), hc_, nullptr); print_value(shell, 4, F("Current flow temperature"), flowTemp_, F_(degrees), 10); print_value(shell, 4, F("Setpoint flow temperature"), flowSetTemp_, F_(degrees)); - print_value(shell, 4, F("Current pump modulation"), pumpMod_, F_(percent)); - print_value(shell, 4, F("Current valve status"), status_, nullptr); + print_value(shell, 4, F("Current pump status"), pump_, nullptr, EMS_VALUE_BOOL); + print_value(shell, 4, F("Current valve status"), status_, F_(percent)); } @@ -121,6 +121,7 @@ void Mixing::show_values(uuid::console::Shell & shell) { // ideally we should group up all the mixing units together into a nested JSON but for now we'll send them individually void Mixing::publish_values() { StaticJsonDocument doc; + char s[5]; // for formatting strings switch (type_) { case Type::HC: @@ -128,23 +129,23 @@ void Mixing::publish_values() { if (Helpers::hasValue(flowTemp_)) { doc["flowTemp"] = (float)flowTemp_ / 10; } - if (Helpers::hasValue(pumpMod_)) { - doc["pumpMod"] = pumpMod_; - } - if (Helpers::hasValue(status_)) { - doc["status"] = status_; - } if (Helpers::hasValue(flowSetTemp_)) { doc["flowSetTemp"] = flowSetTemp_; } + if (Helpers::hasValue(pump_)) { + doc["pumpStatus"] = Helpers::render_value(s, pump_, EMS_VALUE_BOOL); + } + if (Helpers::hasValue(status_)) { + doc["valveStatus"] = status_; + } break; case Type::WWC: doc["type"] = "wwc"; if (Helpers::hasValue(flowTemp_)) { doc["wwTemp"] = (float)flowTemp_ / 10; } - if (Helpers::hasValue(pumpMod_)) { - doc["pumpStatus"] = pumpMod_; + if (Helpers::hasValue(pump_)) { + doc["pumpStatus"] = pump_; } if (Helpers::hasValue(status_)) { doc["tempStatus"] = status_; @@ -156,7 +157,6 @@ void Mixing::publish_values() { } char topic[30]; - char s[3]; // for formatting strings strlcpy(topic, "mixing_data", 30); strlcat(topic, Helpers::itoa(s, get_device_id() - 0x20 + 1), 30); // append hc to topic Mqtt::publish(topic, doc); @@ -170,8 +170,8 @@ void Mixing::process_MMPLUSStatusMessage_HC(std::shared_ptr tele hc_ = telegram->type_id - 0x02D7 + 1; // determine which circuit this is changed_ |= telegram->read_value(flowTemp_, 3); // is * 10 changed_ |= telegram->read_value(flowSetTemp_, 5); - changed_ |= telegram->read_value(pumpMod_, 2); - changed_ |= telegram->read_value(status_, 1); // valve status + changed_ |= telegram->read_value(pump_, 0); + changed_ |= telegram->read_value(status_, 2); // valve status } // Mixing module warm water loading/DHW - 0x0331, 0x0332 @@ -181,7 +181,7 @@ void Mixing::process_MMPLUSStatusMessage_WWC(std::shared_ptr tel type_ = Type::WWC; hc_ = telegram->type_id - 0x0331 + 1; // determine which circuit this is. There are max 2. changed_ |= telegram->read_value(flowTemp_, 0); // is * 10 - changed_ |= telegram->read_value(pumpMod_, 2); + changed_ |= telegram->read_value(pump_, 2); changed_ |= telegram->read_value(status_, 11); // temp status } @@ -201,11 +201,7 @@ void Mixing::process_IPMStatusMessage(std::shared_ptr telegram) changed_ |= telegram->read_value(flowSetTemp_, 5); changed_ |= telegram->read_value(status_, 2); // valve status } - uint8_t pump = 0xFF; - changed_ |= telegram->read_bitvalue(pump, 1, 0); // pump is also in unmixed circuits - if (pump != 0xFF) { - pumpMod_ = 100 * pump; - } + changed_ |= telegram->read_bitvalue(pump_, 1, 0); // pump is also in unmixed circuits } // Mixing on a MM10 - 0xAB @@ -219,8 +215,9 @@ void Mixing::process_MMStatusMessage(std::shared_ptr telegram) { // see https://github.com/proddy/EMS-ESP/issues/270 and https://github.com/proddy/EMS-ESP/issues/386#issuecomment-629610918 hc_ = get_device_id() - 0x20 + 1; changed_ |= telegram->read_value(flowTemp_, 1); // is * 10 - changed_ |= telegram->read_value(pumpMod_, 3); + changed_ |= telegram->read_value(pump_, 3); changed_ |= telegram->read_value(flowSetTemp_, 0); + changed_ |= telegram->read_value(status_, 4); // valve status -100 to 100 } #pragma GCC diagnostic push diff --git a/src/devices/mixing.h b/src/devices/mixing.h index 057184ab1..2dac113d2 100644 --- a/src/devices/mixing.h +++ b/src/devices/mixing.h @@ -62,8 +62,8 @@ class Mixing : public EMSdevice { private: uint16_t hc_ = EMS_VALUE_USHORT_NOTSET; uint16_t flowTemp_ = EMS_VALUE_USHORT_NOTSET; - uint8_t pumpMod_ = EMS_VALUE_UINT_NOTSET; - uint8_t status_ = EMS_VALUE_UINT_NOTSET; + uint8_t pump_ = EMS_VALUE_UINT_NOTSET; + int8_t status_ = EMS_VALUE_UINT_NOTSET; uint8_t flowSetTemp_ = EMS_VALUE_UINT_NOTSET; Type type_ = Type::NONE; bool changed_ = false;