From 0838d06ec4025a28311b2a28014cbfb4d6ade5a3 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Wed, 1 Nov 2023 18:20:32 +0100 Subject: [PATCH] Test for fixing #1378 --- src/devices/thermostat.cpp | 46 +++++++++++++++----------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 798795cbb..341f684c1 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -237,15 +237,23 @@ std::shared_ptr Thermostat::heating_circuit(std::sha // look through the Monitor and Set arrays to see if there is a match uint8_t hc_num = 0; bool toggle_ = false; - // search monitor message types - for (uint8_t i = 0; i < monitor_typeids.size(); i++) { - if (monitor_typeids[i] == telegram->type_id) { - hc_num = i + 1; - toggle_ = true; - break; - } + + // search device-id types for remote thermostats first, they have only a single typeid for all hcs + if (telegram->src >= 0x18 && telegram->src <= 0x1F) { + hc_num = telegram->src - 0x17; + toggle_ = true; } + // not found, search monitor message types + if (hc_num == 0) { + for (uint8_t i = 0; i < monitor_typeids.size(); i++) { + if (monitor_typeids[i] == telegram->type_id) { + hc_num = i + 1; + toggle_ = true; + break; + } + } + } // not found, search status message/set types if (hc_num == 0) { for (uint8_t i = 0; i < set_typeids.size(); i++) { @@ -335,12 +343,6 @@ std::shared_ptr Thermostat::heating_circuit(std::sha } } - // not found, search device-id types for remote thermostats - if (hc_num == 0 && telegram->src >= 0x18 && telegram->src <= 0x1F) { - hc_num = telegram->src - 0x17; - toggle_ = true; - } - // not found, search device-id types for remote thermostats if (hc_num == 0 && telegram->dest >= 0x20 && telegram->dest <= 0x27) { hc_num = telegram->dest - 0x20; @@ -4223,13 +4225,8 @@ void Thermostat::register_device_values_hc(std::shared_ptrremoteseltemp, - DeviceValueType::INT, - DeviceValueNumOp::DV_NUMOP_DIV2, - FL_(remoteseltemp), - DeviceValueUOM::DEGREES); - // a command is only accepted from the remote device, not from ems-esp. + register_device_value(tag, &hc->remoteseltemp, DeviceValueType::INT, DeviceValueNumOp::DV_NUMOP_DIV2, FL_(remoteseltemp), DeviceValueUOM::DEGREES); + // a command is only accepted from the remote device, not from ems-esp. register_device_value(tag, &hc->fastHeatup, DeviceValueType::UINT, FL_(fastheatup), DeviceValueUOM::PERCENT, MAKE_CF_CB(set_fastheatup)); register_device_value(tag, &hc->switchonoptimization, @@ -4258,14 +4255,7 @@ void Thermostat::register_device_values_hc(std::shared_ptrremotehum, - DeviceValueType::UINT, - FL_(remotehum), - DeviceValueUOM::PERCENT, - MAKE_CF_CB(set_remotehum), - -1, - 101); + register_device_value(tag, &hc->remotehum, DeviceValueType::UINT, FL_(remotehum), DeviceValueUOM::PERCENT, MAKE_CF_CB(set_remotehum), -1, 101); break; case EMS_DEVICE_FLAG_CRF: