From 84fab951ba66c06c0edc1f8a104c7c590ccd0cf4 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 13 Nov 2023 18:01:14 +0100 Subject: [PATCH] fix RC300 summertemp, mode --- src/devices/thermostat.cpp | 10 +++++----- src/devices/thermostat.h | 2 +- src/emsdevice.cpp | 10 ++++++++++ src/emsdevice.h | 1 + src/version.h | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index bbc5de7fa..188e8e8dc 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -990,7 +990,7 @@ void Thermostat::process_RC300Monitor(std::shared_ptr telegram) // summermode is bit 4 for boilers and bit 6 for heatpumps: 0:winter, 1:summer telegram->read_value(hc->statusbyte, 2); // use summertemp or hpoperatingstate, https://github.com/emsesp/EMS-ESP32/issues/747, #550, #503 - if ((hc->statusbyte & 1) || !is_fetch(summer2_typeids[hc->hc()])) { + if ((hc->statusbyte & 1) || !is_received(summer2_typeids[hc->hc()])) { has_update(hc->summermode, hc->statusbyte & 0x50 ? 1 : 0); has_update(hc->hpoperatingstate, EMS_VALUE_UINT_NOTSET); } else { @@ -1022,7 +1022,7 @@ void Thermostat::process_RC300Set(std::shared_ptr telegram) { // has_update(telegram, hc->selTemp, 10, 1); // single byte conversion, value is * 2 - manual telegram->read_value(hc->mode_new, 21); // 0-off, 1-manual, 2-auto - if (Helpers::hasValue(hc->mode_new)) { + if (hc->mode_new < 3) { has_update(hc->mode, hc->mode_new); } else { uint8_t mode = EMS_VALUE_UINT_NOTSET; @@ -1063,7 +1063,7 @@ void Thermostat::process_RC300Summer(std::shared_ptr telegram) { has_update(telegram, hc->roominfluence, 0); has_update(telegram, hc->roominfl_factor, 1); // is * 10 has_update(telegram, hc->offsettemp, 2); - if (!is_fetch(summer2_typeids[hc->hc()])) { + if (!is_received(summer2_typeids[hc->hc()])) { has_update(telegram, hc->summertemp, 6); has_update(telegram, hc->summersetmode, 7); } @@ -2616,7 +2616,7 @@ bool Thermostat::set_summermode(const char * value, const int8_t id) { uint8_t set; - if (is_fetch(summer2_typeids[hc->hc()])) { + if (is_received(summer2_typeids[hc->hc()])) { if ((hc->statusbyte & 1) && Helpers::value2enum(value, set, FL_(enum_summermode))) { write_command(summer2_typeids[hc->hc()], 0, set, summer2_typeids[hc->hc()]); return true; @@ -3169,7 +3169,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co validate_typeid = set_typeids[hc->hc()]; switch (mode) { case HeatingCircuit::Mode::SUMMER: - if (is_fetch(summer2_typeids[hc->hc()])) { + if (is_received(summer2_typeids[hc->hc()])) { offset = 0x01; set_typeid = summer2_typeids[hc->hc()]; } else { diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index 4fa450143..3ad8bec68 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -41,7 +41,7 @@ class Thermostat : public EMSdevice { uint8_t tempautotemp; int8_t remoteseltemp; uint8_t mode; - uint8_t mode_new; + uint8_t mode_new = EMS_VALUE_UINT_NOTSET; // not initialized by register_value uint8_t modetype; uint8_t summermode; uint8_t holidaymode; diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index aa632f660..8f9b14cc5 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -347,6 +347,16 @@ bool EMSdevice::is_fetch(uint16_t telegram_id) const { return false; } +// get received status of telegramID +bool EMSdevice::is_received(uint16_t telegram_id) const { + for (const auto & tf : telegram_functions_) { + if (tf.telegram_type_id_ == telegram_id) { + return tf.received_; + } + } + return false; +} + // check for a tag to create a nest bool EMSdevice::has_tags(const uint8_t tag) const { for (const auto & dv : devicevalues_) { diff --git a/src/emsdevice.h b/src/emsdevice.h index 0f917fdc9..d0133c2bc 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -314,6 +314,7 @@ class EMSdevice { void fetch_values(); void toggle_fetch(uint16_t telegram_id, bool toggle); bool is_fetch(uint16_t telegram_id) const; + bool is_received(uint16_t telegram_id) const; bool has_telegram_id(uint16_t id) const; void ha_config_clear(); diff --git a/src/version.h b/src/version.h index 853af4be9..4a56be2f2 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.6.3-test.7a" +#define EMSESP_APP_VERSION "3.6.3-test.7b"