From bf1ce5150a1628baf6a8ad7d5cb2fa60d5089a05 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 11 Aug 2022 09:19:53 +0200 Subject: [PATCH] map RC100H values to device and tag hc --- src/devices/thermostat.cpp | 50 ++++++++++++++------------------------ src/devices/thermostat.h | 16 ++++++------ 2 files changed, 26 insertions(+), 40 deletions(-) diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 81fe2a5e5..264777f04 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -33,8 +33,7 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i register_telegram_type(0x042B, F("RemoteTemp"), false, MAKE_PF_CB(process_RemoteTemp)); register_telegram_type(0x047B, F("RemoteHumidity"), false, MAKE_PF_CB(process_RemoteHumidity)); register_telegram_type(0x0273, F("RemoteCorrection"), true, MAKE_PF_CB(process_RemoteCorrection)); - monitor_typeids = {}; - set_typeids = {}; + register_device_values(); // register device values for common values (not heating circuit) return; // no values to add } // common telegram handlers @@ -302,12 +301,6 @@ std::shared_ptr Thermostat::heating_circuit(std::sha toggle_ = true; } - // not found, search device-id types for remote thermostats - if (hc_num == 0 && telegram->src >= 0x38 && telegram->src <= 0x3F) { - hc_num = telegram->src - 0x37; - 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; @@ -701,27 +694,18 @@ void Thermostat::process_RC20Remote(std::shared_ptr telegram) { // 0x42B - for reading the roomtemperature from the RC100H remote thermostat (0x38, 0x39, ..) // e.g. "38 10 FF 00 03 2B 00 D1 08 2A 01" void Thermostat::process_RemoteTemp(std::shared_ptr telegram) { - std::shared_ptr hc = heating_circuit(telegram); - if (hc == nullptr) { - return; - } - has_update(telegram, hc->remotetemp, 0); + has_update(telegram, tempsensor1_, 0); } // 0x47B - for reading humidity from the RC100H remote thermostat (0x38, 0x39, ..) // e.g. "38 10 FF 00 03 7B 08 24 00 4B" void Thermostat::process_RemoteHumidity(std::shared_ptr telegram) { - std::shared_ptr hc = heating_circuit(telegram); - if (hc == nullptr) { - return; - } - has_update(telegram, hc->dewtemperature, 0); - has_update(telegram, hc->humidity, 1); + has_update(telegram, dewtemperature_, 0); + has_update(telegram, humidity_, 1); } // 0x273 - for reading temperaturcorrection from the RC100H remote thermostat (0x38, 0x39, ..) void Thermostat::process_RemoteCorrection(std::shared_ptr telegram) { - heating_circuit(telegram); // create hc if it does not exist yet has_update(telegram, ibaCalIntTemperature_, 0); } @@ -3390,6 +3374,18 @@ bool Thermostat::set_remoteseltemp(const char * value, const int8_t id) { // register main device values, top level for all thermostats (excluding heating circuits) // as these are done in void Thermostat::register_device_values_hc() void Thermostat::register_device_values() { + // RC100H remote with humidity, this is also EMS_DEVICE_FLAG_RC100 for set_calinttemp + if (device_id() >= 0x38 && device_id() <= 0x3F) { + // each device controls only one hc, so we tag the values + uint8_t tag = DeviceValueTAG::TAG_HC1 + device_id() - 0x38; + register_device_value(tag, &tempsensor1_, DeviceValueType::SHORT, FL_(div10), FL_(remotetemp), DeviceValueUOM::DEGREES); + register_device_value(tag, &dewtemperature_, DeviceValueType::INT, nullptr, FL_(dewTemperature), DeviceValueUOM::DEGREES); + register_device_value(tag, &humidity_, DeviceValueType::INT, nullptr, FL_(airHumidity), DeviceValueUOM::PERCENT); + register_device_value( + tag, &ibaCalIntTemperature_, DeviceValueType::INT, FL_(div10), FL_(ibaCalIntTemperature), DeviceValueUOM::DEGREES_R, MAKE_CF_CB(set_calinttemp)); + return; + } + // Common for all thermostats register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &errorCode_, DeviceValueType::STRING, nullptr, FL_(errorCode), DeviceValueUOM::NONE); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &lastCode_, DeviceValueType::STRING, nullptr, FL_(lastCode), DeviceValueUOM::NONE); @@ -3785,8 +3781,8 @@ void Thermostat::register_device_values() { FL_(ibaMinExtTemperature), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_minexttemp)); - register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &tempsensor1_, DeviceValueType::USHORT, FL_(div10), FL_(tempsensor1), DeviceValueUOM::DEGREES); - register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &tempsensor2_, DeviceValueType::USHORT, FL_(div10), FL_(tempsensor2), DeviceValueUOM::DEGREES); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &tempsensor1_, DeviceValueType::SHORT, FL_(div10), FL_(tempsensor1), DeviceValueUOM::DEGREES); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &tempsensor2_, DeviceValueType::SHORT, FL_(div10), FL_(tempsensor2), DeviceValueUOM::DEGREES); register_device_value( DeviceValueTAG::TAG_DEVICE_DATA, &ibaDamping_, DeviceValueType::BOOL, nullptr, FL_(damping), DeviceValueUOM::NONE, MAKE_CF_CB(set_damping)); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &dampedoutdoortemp_, DeviceValueType::INT, nullptr, FL_(dampedoutdoortemp), DeviceValueUOM::DEGREES); @@ -3979,16 +3975,6 @@ void Thermostat::register_device_values_hc(std::shared_ptrhc(); - // RC300 remote with humidity, this is also EMS_DEVICE_FLAG_RC100 for set_calinttemp - if (device_id() >= 0x38 && device_id() <= 0x3F) { - register_device_value(tag, &hc->remotetemp, DeviceValueType::SHORT, FL_(div10), FL_(remotetemp), DeviceValueUOM::DEGREES); - register_device_value(tag, &hc->dewtemperature, DeviceValueType::UINT, nullptr, FL_(dewTemperature), DeviceValueUOM::DEGREES); - register_device_value(tag, &hc->humidity, DeviceValueType::UINT, nullptr, FL_(airHumidity), DeviceValueUOM::PERCENT); - register_device_value( - tag, &ibaCalIntTemperature_, DeviceValueType::INT, FL_(div10), FL_(ibaCalIntTemperature), DeviceValueUOM::DEGREES_R, MAKE_CF_CB(set_calinttemp)); - return; - } - // different logic on how temperature values are stored, depending on model const __FlashStringHelper * const * seltemp_divider; const __FlashStringHelper * const * roomtemp_divider; diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index 2617c9d1e..61e28d3ec 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -84,8 +84,6 @@ class Thermostat : public EMSdevice { uint8_t climate; uint8_t switchonoptimization; uint8_t statusbyte; // from RC300monitor - uint8_t humidity; - uint8_t dewtemperature; // RC 10 uint8_t reducehours; // night reduce duration @@ -197,12 +195,14 @@ class Thermostat : public EMSdevice { uint8_t offtemp_; // Set Temperature when mode is Off / 10 (e.g.: 0x0F = 7.5 degrees Celsius) uint8_t mixingvalves_; // Number of Mixing Valves: (0x00=0, 0x01=1, 0x02=2) - int8_t dampedoutdoortemp_; - uint16_t tempsensor1_; - uint16_t tempsensor2_; - int16_t dampedoutdoortemp2_; - uint8_t floordrystatus_; - uint8_t floordrytemp_; + int8_t dampedoutdoortemp_; + int16_t tempsensor1_; + int16_t tempsensor2_; + int16_t dampedoutdoortemp2_; + uint8_t floordrystatus_; + uint8_t floordrytemp_; + uint8_t dewtemperature_; + uint8_t humidity_; uint8_t wwExtra1_; // wwExtra active for wwSystem 1 uint8_t wwExtra2_;