From eaf651a4e205f980b0cd31c70dc9db4b01c69454 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 31 Jan 2022 10:12:50 +0100 Subject: [PATCH] fix #336, map Junkers hc3/4 to masterthermostat --- src/device_library.h | 2 ++ src/emsesp.cpp | 14 ++++++++++++++ src/locale_EN.h | 2 +- src/telegram.cpp | 5 +++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/device_library.h b/src/device_library.h index 937b2e0f6..9d56e4602 100644 --- a/src/device_library.h +++ b/src/device_library.h @@ -101,6 +101,8 @@ {106, DeviceType::THERMOSTAT, F("FW200"), DeviceFlags::EMS_DEVICE_FLAG_JUNKERS}, {107, DeviceType::THERMOSTAT, F("FR100"), DeviceFlags::EMS_DEVICE_FLAG_JUNKERS | DeviceFlags::EMS_DEVICE_FLAG_JUNKERS_OLD}, // older model {108, DeviceType::THERMOSTAT, F("FR110"), DeviceFlags::EMS_DEVICE_FLAG_JUNKERS | DeviceFlags::EMS_DEVICE_FLAG_JUNKERS_OLD}, // older model +{109, DeviceType::THERMOSTAT, F("FB10"), DeviceFlags::EMS_DEVICE_FLAG_JUNKERS}, +{110, DeviceType::THERMOSTAT, F("FB100"), DeviceFlags::EMS_DEVICE_FLAG_JUNKERS}, {111, DeviceType::THERMOSTAT, F("FR10"), DeviceFlags::EMS_DEVICE_FLAG_JUNKERS | DeviceFlags::EMS_DEVICE_FLAG_JUNKERS_OLD}, // older model {147, DeviceType::THERMOSTAT, F("FR50"), DeviceFlags::EMS_DEVICE_FLAG_JUNKERS | DeviceFlags::EMS_DEVICE_FLAG_JUNKERS_OLD}, {191, DeviceType::THERMOSTAT, F("FR120"), DeviceFlags::EMS_DEVICE_FLAG_JUNKERS | DeviceFlags::EMS_DEVICE_FLAG_JUNKERS_OLD}, // older model diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 1485f7150..735d6b297 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -174,6 +174,9 @@ void EMSESP::scan_devices() { * we send to right device and match all reads to 0x18 */ uint8_t EMSESP::check_master_device(const uint8_t device_id, const uint16_t type_id, const bool read) { + if (device_id != 0x10 && (device_id < 0x18 || device_id > 0x1F)) { + return device_id; + } if (actual_master_thermostat_ == 0x18) { uint16_t mon_ids[] = {0x02A5, 0x02A6, 0x02A7, 0x02A8, 0x02A9, 0x02AA, 0x02AB, 0x02AC}; uint16_t set_ids[] = {0x02B9, 0x02BA, 0x02BB, 0x02BC, 0x02BD, 0x02BE, 0x02BF, 0x02C0}; @@ -199,6 +202,17 @@ uint8_t EMSESP::check_master_device(const uint8_t device_id, const uint16_t type return 0x18; } } + } else if (actual_master_thermostat_ == 0x10) { + // Junkers FW200 supports hc1/hc2, hc3/hc4 handled by devices 0x1A... + // see https://github.com/emsesp/EMS-ESP32/issues/336 + uint16_t mon_ids[] = {0x0171, 0x0172}; + uint16_t set_ids[] = {0x0167, 0x0168}; + for (uint8_t i = 0; i < sizeof(mon_ids) / 2; i++) { + if (type_id == mon_ids[i] || type_id == set_ids[i]) { + // reads to master thermostat, writes to remote thermostats + return (read ? actual_master_thermostat_ : 0x1A + i); + } + } } return device_id; diff --git a/src/locale_EN.h b/src/locale_EN.h index f28d9f5ce..e1356b759 100644 --- a/src/locale_EN.h +++ b/src/locale_EN.h @@ -375,7 +375,7 @@ MAKE_PSTR_LIST(enum_controlmode, F_(off), F_(optimized), F_(simple), F_(mpc), F_ MAKE_PSTR_LIST(enum_controlmode2, F_(outdoor), F_(room)) // MAKE_PSTR_LIST(enum_controlmode3, F_(off), F_(room), F_(outdoor), F("room+outdoor")) MAKE_PSTR_LIST(enum_control, F_(off), F_(rc20), F_(rc3x)) -MAKE_PSTR_LIST(enum_j_control, F_(off), F("fb10"), F("fb110")) +MAKE_PSTR_LIST(enum_j_control, F_(off), F("fb10"), F("fb100")) MAKE_PSTR_LIST(enum_wwProgMode, F("std_prog"), F_(own_prog)) MAKE_PSTR_LIST(enum_dayOfWeek, F("mo"), F("tu"), F("we"), F("th"), F("fr"), F("sa"), F("so"), F("all")) diff --git a/src/telegram.cpp b/src/telegram.cpp index 8414f1333..9c2a5084b 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -359,8 +359,9 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) { telegram_raw[message_p++] = telegram->message_data[i]; } } - - telegram_last_ = std::make_shared(*telegram); // make a copy of the telegram + // make a copy of the telegram with new dest + telegram_last_ = + std::make_shared(telegram->operation, telegram->src, dest, telegram->type_id, telegram->offset, telegram->message_data, telegram->message_length); uint8_t length = message_p; telegram_raw[length] = calculate_crc(telegram_raw, length); // generate and append CRC to the end