From 5ec0f657a06bb948fb22316c67e40e707c591afb Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 5 Dec 2024 10:09:26 +0100 Subject: [PATCH] newer CT200 temperatures, #2277 --- src/devices/thermostat.cpp | 24 +++++++++++++++++++++--- src/emsdevice.h | 8 ++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 0c50654a9..b233911f9 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -133,6 +133,7 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i monitor_typeids = {0x0A}; set_typeids = {}; register_telegram_type(monitor_typeids[0], "EasyMonitor", true, MAKE_PF_CB(process_EasyMonitor)); + register_telegram_type(0x02A5, "EasyMonitor", false, MAKE_PF_CB(process_EasyMonitor)); // CRF } else if (model == EMSdevice::EMS_DEVICE_FLAG_CRF) { @@ -840,13 +841,30 @@ void Thermostat::process_RC20Monitor(std::shared_ptr telegram) { // type 0x0A - data from the Nefit Easy/TC100 thermostat (0x18) - 31 bytes long void Thermostat::process_EasyMonitor(std::shared_ptr telegram) { - auto hc = heating_circuit(telegram); + monitor_typeids[0] = telegram->type_id; + auto hc = heating_circuit(telegram); if (hc == nullptr) { return; } - has_update(telegram, hc->roomTemp, 8); // is * 100 - has_update(telegram, hc->selTemp, 10); // is * 100 + if (telegram->type_id == 0x0A) { + int16_t temp = hc->roomTemp; + if (telegram->read_value(temp, 8) && temp != 0) { + has_update(telegram, hc->roomTemp, 8); // is * 100 + has_update(telegram, hc->selTemp, 10); // is * 100 + toggle_fetch(0x0A, true); + } + } else if (telegram->type_id == 0x02A5) { // see #2277 + int16_t temp = hc->roomTemp / 10; + if (telegram->read_value(temp, 0)) { // is * 10 + has_update(hc->roomTemp, temp * 10); // * 100 + toggle_fetch(0x0A, false); + } + int16_t sel = hc->selTemp / 50; + if (telegram->read_value(sel, 6, 1)) { // is * 2 + has_update(hc->selTemp, sel * 50); // * 100 + } + } add_ha_climate(hc); } diff --git a/src/emsdevice.h b/src/emsdevice.h index e4ce9743e..99f1a90c9 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -174,6 +174,14 @@ class EMSdevice { } } + void has_update(int16_t & value, int16_t newvalue) { + if (value != newvalue) { + value = newvalue; + has_update_ = true; + publish_value((void *)&value); + } + } + void has_update(uint32_t & value, uint32_t newvalue) { if (value != newvalue) { value = newvalue;