From dbb2a365cb340635fa8c228b5baf80aaa87cb323 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 17 Oct 2022 10:10:42 +0200 Subject: [PATCH 1/4] solar temperature #687 --- src/devices/boiler.cpp | 2 ++ src/devices/boiler.h | 1 + src/locale_translations.h | 1 + 3 files changed, 4 insertions(+) diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index dba21e39b..58fda22fc 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -577,6 +577,7 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const FL_(wwSelTempSingle), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_ww_temp_single)); + register_device_value(DeviceValueTAG::TAG_BOILER_DATA_WW, &wwSolarTemp_, DeviceValueType::USHORT, FL_(wwSolarTemp), DeviceValueUOM::DEGREES); register_device_value(DeviceValueTAG::TAG_BOILER_DATA_WW, &wwType_, DeviceValueType::ENUM, FL_(enum_flow), FL_(wwType), DeviceValueUOM::NONE); register_device_value(DeviceValueTAG::TAG_BOILER_DATA_WW, &wwComfort_, @@ -873,6 +874,7 @@ void Boiler::process_UBAMonitorWW(std::shared_ptr telegram) { has_update(telegram, wwType_, 8); has_update(telegram, wwCurFlow_, 9); + has_update(telegram, wwSolarTemp_, 17); has_update(telegram, wwWorkM_, 10, 3); // force to 3 bytes has_update(telegram, wwStarts_, 13, 3); // force to 3 bytes diff --git a/src/devices/boiler.h b/src/devices/boiler.h index 8f35b147b..a360fcf73 100644 --- a/src/devices/boiler.h +++ b/src/devices/boiler.h @@ -90,6 +90,7 @@ class Boiler : public EMSdevice { uint8_t wwTapActivated_; // maintenance-mode to switch DHW off uint16_t wwMixerTemp_; // mixing temperature uint16_t wwCylMiddleTemp_; // Cyl middle temperature (TS3) + uint16_t wwSolarTemp_; // main uint8_t reset_; // for reset command diff --git a/src/locale_translations.h b/src/locale_translations.h index 3794e054e..4c10dc98b 100644 --- a/src/locale_translations.h +++ b/src/locale_translations.h @@ -457,6 +457,7 @@ MAKE_PSTR_LIST(wwProgMode, "wwprogmode", "program", "Programmmodus", "Programma" MAKE_PSTR_LIST(wwCircProg, "wwcircprog", "circulation program", "Zirkulationsprogramm", "Circulatieprogramma", "Cirkulationsprogram", "program cyrkulacji c.w.u.") MAKE_PSTR_LIST(wwMaxTemp, "wwmaxtemp", "maximum temperature", "Maximale Temperatur", "Maximale temperatuur", "Maximal Temperatur", "temperatura maksymalna") MAKE_PSTR_LIST(wwOneTimeKey, "wwonetimekey", "one time key function", "Einmalladungstaste", "Knop voor eenmalig laden buffer", "Engångsfunktion", "przycisk jednorazowego ogrzania") +MAKE_PSTR_LIST(wwSolarTemp, "wwsolartemp", "solar boiler temperature", "Solarboiler Temperatur", "Zonneboiler temperatuur", "", "") // mqtt values / commands From 3e3e7156ecbcaad870d58e6be0396a1a09954bf3 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 17 Oct 2022 10:11:18 +0200 Subject: [PATCH 2/4] fix setting custom min value --- src/emsdevicevalue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emsdevicevalue.cpp b/src/emsdevicevalue.cpp index 29d4e7d2e..dd15a653b 100644 --- a/src/emsdevicevalue.cpp +++ b/src/emsdevicevalue.cpp @@ -340,7 +340,7 @@ bool DeviceValue::get_custom_min(int16_t & val) { if (fahrenheit) { v = (v - (32 * (fahrenheit - 1))) / 1.8; // reset to °C } - if (v > max) { + if (max > 0 && v > max) { return false; } val = v; From d80831e7087c0d998fb531663a9bcfb1f2bb707a Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 17 Oct 2022 10:12:34 +0200 Subject: [PATCH 3/4] fix possible endless tx repeats on write rejected --- src/emsesp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 688638bde..d65bb6693 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -1191,6 +1191,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) { LOG_ERROR("Last Tx write rejected by host"); txservice_.send_poll(); // close the bus txservice_.reset_retry_count(); + tx_successful = true; } } else if (tx_state == Telegram::Operation::TX_READ) { // got a telegram with data in it. See if the src/dest matches that from the last one we sent and continue to process it From f16aaf7874db1d24abd016a692250f26aa696598 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 17 Oct 2022 10:14:06 +0200 Subject: [PATCH 4/4] ignore mqtt echos if publish_single2command is set. --- src/mqtt.cpp | 10 ++++++++++ src/mqtt.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 7571f7def..06455a1c9 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -55,6 +55,9 @@ uint8_t Mqtt::connectcount_ = 0; uint32_t Mqtt::mqtt_message_id_ = 0; char will_topic_[Mqtt::MQTT_TOPIC_MAX_SIZE]; // because MQTT library keeps only char pointer +std::string Mqtt::lasttopic_ = ""; +std::string Mqtt::lastpayload_ = ""; + // Home Assistant specific // icons from https://materialdesignicons.com used with the UOMs (unit of measurements) MAKE_PSTR_WORD(measurement) @@ -277,6 +280,11 @@ void Mqtt::on_message(const char * topic, const char * payload, size_t len) cons } return; } + // for misconfigured mqtt servers and publish2command ignore echos + if (publish_single_ && publish_single2cmd_ && lasttopic_ == topic && lastpayload_ == message) { + LOG_DEBUG("Received echo message %s: %s", topic, message); + return; + } // check first against any of our subscribed topics for (const auto & mf : mqtt_subfunctions_) { @@ -857,6 +865,8 @@ void Mqtt::process_queue() { // else try and publish it uint16_t packet_id = mqttClient_->publish(topic, mqtt_qos_, message->retain, message->payload.c_str(), message->payload.size(), false, mqtt_message.id_); + lasttopic_ = topic; + lastpayload_ = message->payload; LOG_DEBUG("Publishing topic %s (#%02d, retain=%d, retry=%d, size=%d, pid=%d)", topic, mqtt_message.id_, diff --git a/src/mqtt.h b/src/mqtt.h index b709c3f9b..406752fa8 100644 --- a/src/mqtt.h +++ b/src/mqtt.h @@ -297,6 +297,9 @@ class Mqtt { static uint8_t connectcount_; static bool ha_climate_reset_; + static std::string lasttopic_; + static std::string lastpayload_; + // settings, copied over static std::string mqtt_base_; static std::string mqtt_basename_;