From f942aec67b5099f13c6ac9070b80c5cb32ff2a0a Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 30 May 2024 12:21:32 +0200 Subject: [PATCH] seltemp for CR120 thermostat, #1779 --- src/devices/thermostat.cpp | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index e7cedaef2..900890484 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -1093,8 +1093,13 @@ void Thermostat::process_RC300Set(std::shared_ptr telegram) { // has_update(telegram, hc->selTemp, 8, 1); // single byte conversion, value is * 2 - auto? // has_update(telegram, hc->selTemp, 10, 1); // single byte conversion, value is * 2 - manual - has_update(telegram, hc->mode_new, 21); // for BC400 - has_bitupdate(telegram, hc->mode, 0, 0); // RC300, RC100 + has_update(telegram, hc->mode_new, 21); // for BC400 + // set mode for CR120, https://github.com/emsesp/EMS-ESP32/discussions/1779 + if (Helpers::hasValue(hc->mode_new)) { + has_update(hc->mode, hc->mode_new == 2 ? 1 : 0); + } else { + has_bitupdate(telegram, hc->mode, 0, 0); // RC300, RC100 + } /* telegram->read_value(hc->mode_new, 21); // 0-off, 1-manual, 2-auto if (Helpers::hasValue(hc->mode_new)) { @@ -2815,8 +2820,14 @@ bool Thermostat::set_mode_n(const uint8_t mode, const int8_t id) { case EMSdevice::EMS_DEVICE_FLAG_RC300: case EMSdevice::EMS_DEVICE_FLAG_RC100: case EMSdevice::EMS_DEVICE_FLAG_R3000: - offset = EMS_OFFSET_RCPLUSSet_mode; - set_mode_value = set_mode_value == 2 ? 0xFF : 0; + // CR120, https://github.com/emsesp/EMS-ESP32/discussions/1779 + if (Helpers::hasValue(hc->mode_new)) { // enum: 0- off, 1- manual, 2- auto + offset = EMS_OFFSET_RCPLUSSet_mode_new; + set_mode_value = set_mode_value == 1 ? 2 : 1; + } else { // enum: 0- manual, 1- auto + offset = EMS_OFFSET_RCPLUSSet_mode; + set_mode_value = set_mode_value == 1 ? 0xFF : 0; + } break; case EMSdevice::EMS_DEVICE_FLAG_JUNKERS: if (has_flags(EMSdevice::EMS_DEVICE_FLAG_JUNKERS_OLD)) { @@ -3546,7 +3557,11 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co factor = 1; break; case HeatingCircuit::Mode::MANUAL: - offset = 0x0A; // manual offset + if (Helpers::hasValue(hc->mode_new)) { + offset = 22; // manual offset CR120 + } else { + offset = 10; // manual offset + } break; case HeatingCircuit::Mode::TEMPAUTO: offset = 0x08; // auto offset @@ -3617,13 +3632,14 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co offset = 9; factor = 1; break; - default: - // HeatingCircuit::Mode::AUTO: + default: // seltemp uint8_t mode_ = hc->get_mode(); - if (mode_ == HeatingCircuit::Mode::MANUAL) { - offset = 0x0A; // manual offset + if (Helpers::hasValue(hc->mode_new) && mode_ == HeatingCircuit::Mode::MANUAL) { + offset = 22; // manual offset CR120 + } else if (mode_ == HeatingCircuit::Mode::MANUAL) { + offset = 10; // manual offset } else { - offset = 0x08; // auto offset + offset = 8; // auto offset // special case to reactivate auto temperature, see #737, #746 if (temperature == -1) { factor = 1;