From d2316518acb98e20be6ad122c21659187e2c615b Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 2 Jan 2020 18:05:40 +0100 Subject: [PATCH 1/5] don't detect HCs if there not active - #238 --- scripts/main_script.py | 2 +- src/ems.cpp | 48 ++++++++++++++++++++++-------------------- src/ems.h | 2 +- src/version.h | 2 +- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/scripts/main_script.py b/scripts/main_script.py index 61b873da9..cc0c8b47d 100644 --- a/scripts/main_script.py +++ b/scripts/main_script.py @@ -25,7 +25,7 @@ def clr(color, text): def remove_float_support(): flags = " ".join(env['LINKFLAGS']) - print(clr(Color.BLUE, "** LINKFLAGS = %ss" % flags)) + print(clr(Color.BLUE, "LINKFLAGS = %ss" % flags)) flags = flags.replace("-u _printf_float", "") flags = flags.replace("-u _scanf_float", "") newflags = flags.split() diff --git a/src/ems.cpp b/src/ems.cpp index b13464664..cb383837c 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -1199,7 +1199,10 @@ void _process_RC35StatusMessage(_EMS_RxTelegram * EMS_RxTelegram) { return; } - uint8_t hc_num = _getHeatingCircuit(EMS_RxTelegram); // which HC is it, 0-3 + int8_t hc_num = _getHeatingCircuit(EMS_RxTelegram); // which HC is it, 0-3 + if (hc_num == -1) { + return; + } // ignore if the value is 0 (see https://github.com/proddy/EMS-ESP/commit/ccc30738c00f12ae6c89177113bd15af9826b836) if (EMS_RxTelegram->data[EMS_OFFSET_RC35StatusMessage_setpoint] != 0x00) { @@ -1357,29 +1360,25 @@ void _process_RC30Set(_EMS_RxTelegram * EMS_RxTelegram) { // return which heating circuit it is, 0-3 for HC1 to HC4 // based on type 0x3E (HC1), 0x48 (HC2), 0x52 (HC3), 0x5C (HC4) -uint8_t _getHeatingCircuit(_EMS_RxTelegram * EMS_RxTelegram) { - uint8_t hc_num; - switch (EMS_RxTelegram->type) { - case EMS_TYPE_RC35StatusMessage_HC1: - case EMS_TYPE_RC35Set_HC1: - default: - hc_num = 1; // also default - break; - case EMS_TYPE_RC35StatusMessage_HC2: - case EMS_TYPE_RC35Set_HC2: - hc_num = 2; - break; - case EMS_TYPE_RC35StatusMessage_HC3: - case EMS_TYPE_RC35Set_HC3: - hc_num = 3; - break; - case EMS_TYPE_RC35StatusMessage_HC4: - case EMS_TYPE_RC35Set_HC4: - hc_num = 4; - break; +int8_t _getHeatingCircuit(_EMS_RxTelegram * EMS_RxTelegram) { + // check to see we have an active HC. Assuming first byte must have some bit status set. + // see https://github.com/proddy/EMS-ESP/issues/238 + if (EMS_RxTelegram->data[0] == 0x00) { + return -1; + } + + int8_t hc_num = 0; // default is HC1 + + if ((EMS_RxTelegram->type == EMS_TYPE_RC35StatusMessage_HC2) || (EMS_RxTelegram->type = EMS_TYPE_RC35Set_HC2)) { + hc_num = 1; + } else if ((EMS_RxTelegram->type == EMS_TYPE_RC35StatusMessage_HC3) || (EMS_RxTelegram->type = EMS_TYPE_RC35Set_HC3)) { + hc_num = 2; + } else if ((EMS_RxTelegram->type == EMS_TYPE_RC35StatusMessage_HC4) || (EMS_RxTelegram->type = EMS_TYPE_RC35Set_HC4)) { + hc_num = 3; + } else { + return -1; // not a valid HC } - hc_num--; EMS_Thermostat.hc[hc_num].active = true; return (hc_num); @@ -1400,7 +1399,10 @@ void _process_RC35Set(_EMS_RxTelegram * EMS_RxTelegram) { return; } - uint8_t hc_num = _getHeatingCircuit(EMS_RxTelegram); // which HC is it? + int8_t hc_num = _getHeatingCircuit(EMS_RxTelegram); // which HC is it, 0-3 + if (hc_num == -1) { + return; + } _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].mode, EMS_OFFSET_RC35Set_mode); // night, day, auto _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].daytemp, EMS_OFFSET_RC35Set_temp_day); // is * 2 diff --git a/src/ems.h b/src/ems.h index efc3a3f27..4ffa61eb0 100644 --- a/src/ems.h +++ b/src/ems.h @@ -456,7 +456,7 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram); void _debugPrintPackage(const char * prefix, _EMS_RxTelegram * EMS_RxTelegram, const char * color); void _ems_clearTxData(); void _removeTxQueue(); -uint8_t _getHeatingCircuit(_EMS_RxTelegram * EMS_RxTelegram); +int8_t _getHeatingCircuit(_EMS_RxTelegram * EMS_RxTelegram); // global so can referenced in other classes extern _EMS_Sys_Status EMS_Sys_Status; diff --git a/src/version.h b/src/version.h index 72543df5c..065e5b802 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define APP_VERSION "1.9.5b8" +#define APP_VERSION "1.9.5b9" From 18c6f7a7b72d51faee69157b39384e68c4dadb6a Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 2 Jan 2020 22:45:13 +0100 Subject: [PATCH 2/5] clean up HCs - #238 --- src/ems.cpp | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/ems.cpp b/src/ems.cpp index cb383837c..3f6d2482c 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -1199,22 +1199,22 @@ void _process_RC35StatusMessage(_EMS_RxTelegram * EMS_RxTelegram) { return; } - int8_t hc_num = _getHeatingCircuit(EMS_RxTelegram); // which HC is it, 0-3 - if (hc_num == -1) { + int8_t hc = _getHeatingCircuit(EMS_RxTelegram); // which HC is it, 0-3 + if (hc == -1) { return; } // ignore if the value is 0 (see https://github.com/proddy/EMS-ESP/commit/ccc30738c00f12ae6c89177113bd15af9826b836) if (EMS_RxTelegram->data[EMS_OFFSET_RC35StatusMessage_setpoint] != 0x00) { - _setValue8(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].setpoint_roomTemp, EMS_OFFSET_RC35StatusMessage_setpoint); // is * 2, force to single byte + _setValue8(EMS_RxTelegram, &EMS_Thermostat.hc[hc].setpoint_roomTemp, EMS_OFFSET_RC35StatusMessage_setpoint); // is * 2, force to single byte } // ignore if the value is unset. Hopefully it will be picked up via a later message - _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].curr_roomTemp, EMS_OFFSET_RC35StatusMessage_curr); // is * 10 - _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].day_mode, EMS_OFFSET_RC35StatusMessage_mode, 1); - _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].summer_mode, EMS_OFFSET_RC35StatusMessage_mode, 0); - _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].holiday_mode, EMS_OFFSET_RC35StatusMessage_mode1, 5); - _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].circuitcalctemp, EMS_OFFSET_RC35Set_circuitcalctemp); + _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].curr_roomTemp, EMS_OFFSET_RC35StatusMessage_curr); // is * 10 + _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].day_mode, EMS_OFFSET_RC35StatusMessage_mode, 1); + _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].summer_mode, EMS_OFFSET_RC35StatusMessage_mode, 0); + _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].holiday_mode, EMS_OFFSET_RC35StatusMessage_mode1, 5); + _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].circuitcalctemp, EMS_OFFSET_RC35Set_circuitcalctemp); } /** @@ -1367,21 +1367,23 @@ int8_t _getHeatingCircuit(_EMS_RxTelegram * EMS_RxTelegram) { return -1; } - int8_t hc_num = 0; // default is HC1 + int8_t hc; - if ((EMS_RxTelegram->type == EMS_TYPE_RC35StatusMessage_HC2) || (EMS_RxTelegram->type = EMS_TYPE_RC35Set_HC2)) { - hc_num = 1; + if ((EMS_RxTelegram->type == EMS_TYPE_RC35StatusMessage_HC1) || (EMS_RxTelegram->type = EMS_TYPE_RC35Set_HC1)) { + hc = 0; + } else if ((EMS_RxTelegram->type == EMS_TYPE_RC35StatusMessage_HC2) || (EMS_RxTelegram->type = EMS_TYPE_RC35Set_HC2)) { + hc = 1; } else if ((EMS_RxTelegram->type == EMS_TYPE_RC35StatusMessage_HC3) || (EMS_RxTelegram->type = EMS_TYPE_RC35Set_HC3)) { - hc_num = 2; + hc = 2; } else if ((EMS_RxTelegram->type == EMS_TYPE_RC35StatusMessage_HC4) || (EMS_RxTelegram->type = EMS_TYPE_RC35Set_HC4)) { - hc_num = 3; + hc = 3; } else { return -1; // not a valid HC } - EMS_Thermostat.hc[hc_num].active = true; + EMS_Thermostat.hc[hc].active = true; - return (hc_num); + return (hc); } /** @@ -1399,16 +1401,16 @@ void _process_RC35Set(_EMS_RxTelegram * EMS_RxTelegram) { return; } - int8_t hc_num = _getHeatingCircuit(EMS_RxTelegram); // which HC is it, 0-3 - if (hc_num == -1) { + int8_t hc = _getHeatingCircuit(EMS_RxTelegram); // which HC is it, 0-3 + if (hc == -1) { return; } - _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].mode, EMS_OFFSET_RC35Set_mode); // night, day, auto - _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].daytemp, EMS_OFFSET_RC35Set_temp_day); // is * 2 - _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].nighttemp, EMS_OFFSET_RC35Set_temp_night); // is * 2 - _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].holidaytemp, EMS_OFFSET_RC35Set_temp_holiday); // is * 2 - _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc_num].heatingtype, EMS_OFFSET_RC35Set_heatingtype); // byte 0 bit floor heating = 3 + _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].mode, EMS_OFFSET_RC35Set_mode); // night, day, auto + _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].daytemp, EMS_OFFSET_RC35Set_temp_day); // is * 2 + _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].nighttemp, EMS_OFFSET_RC35Set_temp_night); // is * 2 + _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].holidaytemp, EMS_OFFSET_RC35Set_temp_holiday); // is * 2 + _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].heatingtype, EMS_OFFSET_RC35Set_heatingtype); // byte 0 bit floor heating = 3 } /** From 0af60a320d5b2c7f9b84924529fed7e5ff57611a Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 3 Jan 2020 11:24:12 +0100 Subject: [PATCH 3/5] writing to Junkers thermostats - #138 --- CHANGELOG.md | 1 + src/ems.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++---- src/ems_devices.h | 25 +++++++++++++---- src/version.h | 2 +- 4 files changed, 86 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 714ded96c..9ec62a5f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Solar Module SM200 support - `set master_thermostat ` to choose with thermostat is master when there are multiple on the bus - MM10 Mixer support (thanks @MichaelDvP) +- First implementation of writing to Junker Thermostats (thanks @Neonox31) ### Fixed - set boiler warm water temp on Junkers/Bosch HT3 diff --git a/src/ems.cpp b/src/ems.cpp index 3f6d2482c..8a0b16cc0 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -534,7 +534,7 @@ void _ems_sendTelegram() { _EMS_RxTelegram EMS_RxTelegram; // create new Rx object EMS_RxTelegram.length = EMS_TxTelegram.length; // full length of telegram EMS_RxTelegram.telegram = EMS_TxTelegram.data; - EMS_RxTelegram.data_length = 0; // ignore #data= + EMS_RxTelegram.data_length = 0; // surpress #data= EMS_RxTelegram.timestamp = myESP.getSystemTime(); // now _debugPrintTelegram("Sending raw: ", &EMS_RxTelegram, COLOR_CYAN, true); } @@ -1209,7 +1209,6 @@ void _process_RC35StatusMessage(_EMS_RxTelegram * EMS_RxTelegram) { _setValue8(EMS_RxTelegram, &EMS_Thermostat.hc[hc].setpoint_roomTemp, EMS_OFFSET_RC35StatusMessage_setpoint); // is * 2, force to single byte } - // ignore if the value is unset. Hopefully it will be picked up via a later message _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].curr_roomTemp, EMS_OFFSET_RC35StatusMessage_curr); // is * 10 _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].day_mode, EMS_OFFSET_RC35StatusMessage_mode, 1); _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].summer_mode, EMS_OFFSET_RC35StatusMessage_mode, 0); @@ -1290,13 +1289,15 @@ void _process_RCPLUSStatusMode(_EMS_RxTelegram * EMS_RxTelegram) { } /** - * FR10/FR50/FR100 Junkers - type x006F + * FR10/FR50/FR100 Junkers - type x6F * e.g. for FR10: 90 00 FF 00 00 6F 03 01 00 BE 00 BF * for FW100: 90 00 FF 00 00 6F 03 02 00 D7 00 DA F3 34 00 C4 */ void _process_JunkersStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) { - uint8_t hc = EMS_THERMOSTAT_DEFAULTHC - 1; // use HC1 - EMS_Thermostat.hc[hc].active = true; + int8_t hc = _getHeatingCircuit(EMS_RxTelegram); // which HC is it, 0-3 + if (hc == -1) { + return; + } _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].curr_roomTemp, EMS_OFFSET_JunkersStatusMessage_curr); // value is * 10 _setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].setpoint_roomTemp, EMS_OFFSET_JunkersStatusMessage_setpoint); // value is * 10 @@ -2286,6 +2287,44 @@ void ems_setThermostatTemp(float temperature, uint8_t hc_num, uint8_t temptype) EMS_TxTelegram.type_validate = EMS_TxTelegram.type; } + else if (model == EMS_DEVICE_FLAG_JUNKERS) { + switch (temptype) { + case 1: // change the no frost temp + EMS_TxTelegram.offset = EMS_OFFSET_JunkersSetMessage_no_frost_temp; + break; + case 2: // change the night temp + EMS_TxTelegram.offset = EMS_OFFSET_JunkersSetMessage_night_temp; + break; + case 3: // change the day temp + EMS_TxTelegram.offset = EMS_OFFSET_JunkersSetMessage_day_temp; + break; + default: + case 0: // automatic selection, if no type is defined, we use the standard code + // not sure if this is correct for Junkers + if (EMS_Thermostat.hc[hc_num - 1].day_mode == 0) { + EMS_TxTelegram.offset = EMS_OFFSET_JunkersSetMessage_night_temp; + } else if (EMS_Thermostat.hc[hc_num - 1].day_mode == 1) { + EMS_TxTelegram.offset = EMS_OFFSET_JunkersSetMessage_day_temp; + } + break; + } + + if (hc_num == 1) { + EMS_TxTelegram.type = EMS_TYPE_JunkersSetMessage_HC1; + EMS_TxTelegram.comparisonPostRead = EMS_TYPE_JunkersStatusMessage_HC1; + } else if (hc_num == 2) { + EMS_TxTelegram.type = EMS_TYPE_JunkersSetMessage_HC1; + EMS_TxTelegram.comparisonPostRead = EMS_TYPE_JunkersStatusMessage_HC1; + } else if (hc_num == 3) { + EMS_TxTelegram.type = EMS_TYPE_JunkersSetMessage_HC1; + EMS_TxTelegram.comparisonPostRead = EMS_TYPE_JunkersStatusMessage_HC1; + } else if (hc_num == 4) { + EMS_TxTelegram.type = EMS_TYPE_JunkersSetMessage_HC1; + EMS_TxTelegram.comparisonPostRead = EMS_TYPE_JunkersStatusMessage_HC1; + } + EMS_TxTelegram.type_validate = EMS_TxTelegram.type; + } + EMS_TxTelegram.length = EMS_MIN_TELEGRAM_LENGTH; EMS_TxTelegram.dataValue = (uint8_t)((float)temperature * (float)2); // value * 2 EMS_TxTelegram.comparisonOffset = EMS_TxTelegram.offset; @@ -2379,6 +2418,23 @@ void ems_setThermostatMode(uint8_t mode, uint8_t hc_num) { EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_mode; EMS_TxTelegram.type_validate = EMS_TxTelegram.type; + } else if (model == EMS_DEVICE_FLAG_JUNKERS) { + if (hc_num == 1) { + EMS_TxTelegram.type = EMS_TYPE_JunkersSetMessage_HC1; + EMS_TxTelegram.comparisonPostRead = EMS_TYPE_JunkersStatusMessage_HC1; + } else if (hc_num == 2) { + EMS_TxTelegram.type = EMS_TYPE_JunkersSetMessage_HC2; + EMS_TxTelegram.comparisonPostRead = EMS_TYPE_JunkersStatusMessage_HC2; + } else if (hc_num == 3) { + EMS_TxTelegram.type = EMS_TYPE_JunkersSetMessage_HC3; + EMS_TxTelegram.comparisonPostRead = EMS_TYPE_JunkersStatusMessage_HC3; + } else if (hc_num == 4) { + EMS_TxTelegram.type = EMS_TYPE_JunkersSetMessage_HC4; + EMS_TxTelegram.comparisonPostRead = EMS_TYPE_JunkersStatusMessage_HC4; + } + EMS_TxTelegram.offset = EMS_OFFSET_JunkersSetMessage_set_mode; + EMS_TxTelegram.type_validate = EMS_TxTelegram.type; + } else if (model == EMS_DEVICE_FLAG_RC300) { EMS_TxTelegram.offset = EMS_OFFSET_RCPLUSSet_mode; @@ -2720,7 +2776,10 @@ const _EMS_Type EMS_Types[] = { {EMS_DEVICE_UPDATE_FLAG_THERMOSTAT, EMS_TYPE_RCPLUSStatusMode, "RCPLUSStatusMode", _process_RCPLUSStatusMode}, // Junkers FR10 - {EMS_DEVICE_UPDATE_FLAG_THERMOSTAT, EMS_TYPE_JunkersStatusMessage, "JunkersStatusMessage", _process_JunkersStatusMessage}, + {EMS_DEVICE_UPDATE_FLAG_THERMOSTAT, EMS_TYPE_JunkersStatusMessage_HC1, "JunkersStatusMessage_HC1", _process_JunkersStatusMessage}, + {EMS_DEVICE_UPDATE_FLAG_THERMOSTAT, EMS_TYPE_JunkersStatusMessage_HC2, "JunkersStatusMessage_HC2", _process_JunkersStatusMessage}, + {EMS_DEVICE_UPDATE_FLAG_THERMOSTAT, EMS_TYPE_JunkersStatusMessage_HC3, "JunkersStatusMessage_HC3", _process_JunkersStatusMessage}, + {EMS_DEVICE_UPDATE_FLAG_THERMOSTAT, EMS_TYPE_JunkersStatusMessage_HC4, "JunkersStatusMessage_HC4", _process_JunkersStatusMessage}, // Mixing devices MM10 - MM400 {EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMPLUSStatusMessage_HC1, "MMPLUSStatusMessage_HC1", _process_MMPLUSStatusMessage}, diff --git a/src/ems_devices.h b/src/ems_devices.h index 5a52eb7ba..2bdeeff68 100644 --- a/src/ems_devices.h +++ b/src/ems_devices.h @@ -181,13 +181,26 @@ const _EMS_Device_Types EMS_Devices_Types[] = { #define EMS_OFFSET_RCPLUSSet_temp_setpoint 8 // temp setpoint, when changing of templevel (in auto) value is reset and set to FF #define EMS_OFFSET_RCPLUSSet_manual_setpoint 10 // manual setpoint -// Junkers FR10, FR50, FW100 (EMS Plus) -#define EMS_TYPE_JunkersStatusMessage 0x6F // is an automatic thermostat broadcast giving us temps +// Junkers FR10, FR50, FW100, FW120 (EMS Plus) +#define EMS_TYPE_JunkersStatusMessage_HC1 0x6F // is an automatic thermostat broadcast giving us temps +#define EMS_TYPE_JunkersStatusMessage_HC2 0x70 // is an automatic thermostat broadcast giving us temps +#define EMS_TYPE_JunkersStatusMessage_HC3 0x71 // is an automatic thermostat broadcast giving us temps +#define EMS_TYPE_JunkersStatusMessage_HC4 0x72 // is an automatic thermostat broadcast giving us temps + #define EMS_OFFSET_JunkersStatusMessage_daymode 0 // 3 = day, 2 = night #define EMS_OFFSET_JunkersStatusMessage_mode 1 // current mode, 1 = manual, 2 = auto #define EMS_OFFSET_JunkersStatusMessage_setpoint 2 // setpoint temp #define EMS_OFFSET_JunkersStatusMessage_curr 4 // current temp +#define EMS_TYPE_JunkersSetMessage_HC1 0x65 // EMS type to set temperature on thermostat for heating circuit 1 +#define EMS_TYPE_JunkersSetMessage_HC2 0x66 // EMS type to set temperature on thermostat for heating circuit 2 +#define EMS_TYPE_JunkersSetMessage_HC3 0x67 // EMS type to set temperature on thermostat for heating circuit 3 +#define EMS_TYPE_JunkersSetMessage_HC4 0x68 // EMS type to set temperature on thermostat for heating circuit 4 +#define EMS_OFFSET_JunkersSetMessage_day_temp 0x11 // EMS offset to set temperature on thermostat for day mode +#define EMS_OFFSET_JunkersSetMessage_night_temp 0x10 // EMS offset to set temperature on thermostat for night mode +#define EMS_OFFSET_JunkersSetMessage_no_frost_temp 0x0F // EMS offset to set temperature on thermostat for no frost mode +#define EMS_OFFSET_JunkersSetMessage_set_mode 0x0E // EMS offset to set mode on thermostat + // MM100 (EMS Plus) #define EMS_TYPE_MMPLUSStatusMessage_HC1 0x01D7 // mixer status HC1 #define EMS_TYPE_MMPLUSStatusMessage_HC2 0x01D8 // mixer status HC2 @@ -294,14 +307,14 @@ static const _EMS_Device EMS_Devices[] = { {76, EMS_DEVICE_TYPE_THERMOSTAT, "Sieger ES73", EMS_DEVICE_FLAG_RC35}, // 0x10 // Junkers - {105, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FW100", EMS_DEVICE_FLAG_JUNKERS | EMS_DEVICE_FLAG_NO_WRITE}, // 0x10, cannot write + {105, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FW100", EMS_DEVICE_FLAG_JUNKERS}, // 0x10 {106, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FW200", EMS_DEVICE_FLAG_JUNKERS | EMS_DEVICE_FLAG_NO_WRITE}, // 0x10, cannot write {107, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FR100", EMS_DEVICE_FLAG_JUNKERS | EMS_DEVICE_FLAG_NO_WRITE}, // 0x10, cannot write {108, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FR110", EMS_DEVICE_FLAG_JUNKERS | EMS_DEVICE_FLAG_NO_WRITE}, // 0x10, cannot write - {111, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FR10", EMS_DEVICE_FLAG_JUNKERS | EMS_DEVICE_FLAG_NO_WRITE}, // 0x10, cannot write + {111, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FR10", EMS_DEVICE_FLAG_JUNKERS}, // 0x10 + {147, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FR50", EMS_DEVICE_FLAG_JUNKERS | EMS_DEVICE_FLAG_NO_WRITE}, // 0x10, cannot write {191, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FR120", EMS_DEVICE_FLAG_JUNKERS | EMS_DEVICE_FLAG_NO_WRITE}, // 0x10, cannot write - {192, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FW120", EMS_DEVICE_FLAG_JUNKERS | EMS_DEVICE_FLAG_NO_WRITE}, // 0x10, cannot write - {147, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FR50", EMS_DEVICE_FLAG_JUNKERS | EMS_DEVICE_FLAG_NO_WRITE} // 0x10, cannot write + {192, EMS_DEVICE_TYPE_THERMOSTAT, "Junkers FW120", EMS_DEVICE_FLAG_JUNKERS} // 0x10 }; diff --git a/src/version.h b/src/version.h index 065e5b802..955986cb8 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define APP_VERSION "1.9.5b9" +#define APP_VERSION "1.9.5b10" From 5ce0b64bb46274a45ad08da7ffc4633054025dad Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 3 Jan 2020 13:10:26 +0100 Subject: [PATCH 4/5] support for multiple productids - #278 --- src/ems.cpp | 30 +++++++++++++++++++----------- src/ems.h | 1 + src/ems_devices.h | 12 ++++++++---- src/version.h | 2 +- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/ems.cpp b/src/ems.cpp index 8a0b16cc0..17de38bfc 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -1707,13 +1707,22 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) { } // scan through known devices matching the productid - uint8_t product_id = EMS_RxTelegram->data[offset]; - uint8_t i = 0; - bool typeFound = false; - while (i < _EMS_Devices_max) { + uint8_t product_id = EMS_RxTelegram->data[offset]; + uint8_t i = 0; + uint8_t found_index = 0; + bool typeFound = false; + while ((i < _EMS_Devices_max) || (!typeFound)) { if (EMS_Devices[i].product_id == product_id) { - typeFound = true; // we have a matching product id. i is the index. - break; + // we have a matching product id + // now lets see if there is a matching device_id since product_id can be on multiple devices + // e.g. with UBAMasters, there is only one device_id 0x08. To avoid https://github.com/proddy/EMS-ESP/issues/271 + _EMS_DEVICE_TYPE device_type = EMS_Devices[i].type; + for (uint8_t j = 0; j < _EMS_Devices_Types_max; j++) { + if ((EMS_Devices_Types[j].device_type == device_type) && (EMS_Devices_Types[j].device_id == device_id)) { + typeFound = true; + found_index = i; + } + } } i++; } @@ -1724,18 +1733,17 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) { return; } - const char * device_desc_p = (EMS_Devices[i].device_desc); // pointer to the full description of the device - _EMS_DEVICE_TYPE type = EMS_Devices[i].type; // type + const char * device_desc_p = (EMS_Devices[found_index].device_desc); // pointer to the full description of the device + _EMS_DEVICE_TYPE type = EMS_Devices[found_index].type; // type // we recognized it, see if we already have it in our recognized list if (_addDevice(type, product_id, device_id, device_desc_p, version)) { return; // already in list } - uint8_t flags = EMS_Devices[i].flags; // its a new entry, set the specifics + uint8_t flags = EMS_Devices[found_index].flags; // it's a new entry, set the specifics - if ((type == EMS_DEVICE_TYPE_BOILER) && (device_id == EMS_ID_BOILER)) { - // with UBAMasters, there is only one device_id 0x08. To avoid https://github.com/proddy/EMS-ESP/issues/271 + if (type == EMS_DEVICE_TYPE_BOILER) { EMS_Boiler.device_id = device_id; EMS_Boiler.product_id = product_id; EMS_Boiler.device_flags = flags; diff --git a/src/ems.h b/src/ems.h index 4ffa61eb0..8c0b05fe7 100644 --- a/src/ems.h +++ b/src/ems.h @@ -211,6 +211,7 @@ typedef enum : uint8_t { EMS_DEVICE_TYPE_SWITCH, EMS_DEVICE_TYPE_CONTROLLER, EMS_DEVICE_TYPE_CONNECT, + EMS_DEVICE_TYPE_MODEM, EMS_DEVICE_TYPE_UNKNOWN } _EMS_DEVICE_TYPE; diff --git a/src/ems_devices.h b/src/ems_devices.h index 2bdeeff68..1fdac9178 100644 --- a/src/ems_devices.h +++ b/src/ems_devices.h @@ -26,6 +26,7 @@ #define EMS_ID_THERMOSTAT1 0x10 // Thermostat #define EMS_ID_THERMOSTAT2 0x17 // Thermostat #define EMS_ID_THERMOSTAT3 0x18 // Thermostat +#define EMS_ID_MODEM 0x19 // Modem // mapping for EMS_Devices_Type const _EMS_Device_Types EMS_Devices_Types[] = { @@ -44,7 +45,8 @@ const _EMS_Device_Types EMS_Devices_Types[] = { {EMS_ID_SWITCH, EMS_DEVICE_TYPE_SWITCH, "Switching Module"}, {EMS_ID_CONTROLLER, EMS_DEVICE_TYPE_CONTROLLER, "Controller"}, {EMS_ID_CONNECT1, EMS_DEVICE_TYPE_CONNECT, "Connect"}, - {EMS_ID_CONNECT2, EMS_DEVICE_TYPE_CONNECT, "Connect"} + {EMS_ID_CONNECT2, EMS_DEVICE_TYPE_CONNECT, "Connect"}, + {EMS_ID_MODEM, EMS_DEVICE_TYPE_MODEM, "Modem"} }; @@ -257,7 +259,7 @@ static const _EMS_Device EMS_Devices[] = { {159, EMS_DEVICE_TYPE_MIXING, "MM50 Mixing Module", EMS_DEVICE_FLAG_NONE}, {79, EMS_DEVICE_TYPE_MIXING, "MM100 Mixer Module", EMS_DEVICE_FLAG_NONE}, {80, EMS_DEVICE_TYPE_MIXING, "MM200 Mixer Module", EMS_DEVICE_FLAG_NONE}, - //{78, EMS_DEVICE_TYPE_MIXING, "MM400 Mixer Module", EMS_DEVICE_FLAG_NONE}, + {78, EMS_DEVICE_TYPE_MIXING, "MM400 Mixer Module", EMS_DEVICE_FLAG_NONE}, // // HeatPump - type 0x38 @@ -266,7 +268,8 @@ static const _EMS_Device EMS_Devices[] = { {200, EMS_DEVICE_TYPE_HEATPUMP, "HeatPump Module", EMS_DEVICE_FLAG_NONE}, // - // Other devices, like 0x11 for Switching, 0x09 for controllers, 0x02 for Connect, 0x48 for Gateway + // Other devices like controllers and modems + // such as 0x11 for Switching, 0x09 for controllers, 0x02 for Connect, 0x48 for Gateway // {71, EMS_DEVICE_TYPE_SWITCH, "WM10 Switch Module", EMS_DEVICE_FLAG_NONE}, // 0x11 {68, EMS_DEVICE_TYPE_CONTROLLER, "BC10/RFM20 Receiver", EMS_DEVICE_FLAG_NONE}, // 0x09 @@ -283,6 +286,7 @@ static const _EMS_Device EMS_Devices[] = { {206, EMS_DEVICE_TYPE_CONNECT, "Bosch Easy Connect", EMS_DEVICE_FLAG_NONE}, // 0x02 {171, EMS_DEVICE_TYPE_CONNECT, "EMS-OT OpenTherm converter", EMS_DEVICE_FLAG_NONE}, // 0x02 {189, EMS_DEVICE_TYPE_GATEWAY, "Web Gateway KM200", EMS_DEVICE_FLAG_NONE}, // 0x48 + {94, EMS_DEVICE_TYPE_MODEM, "RC Remote Device", EMS_DEVICE_FLAG_NONE}, // 0x19 // // Thermostats, typically device id of 0x10, 0x17, 0x18 and 0x39 (easy) @@ -296,10 +300,10 @@ static const _EMS_Device EMS_Devices[] = { // Buderus/Nefit {79, EMS_DEVICE_TYPE_THERMOSTAT, "RC10/Moduline 100", EMS_DEVICE_FLAG_RC10}, // 0x17 {77, EMS_DEVICE_TYPE_THERMOSTAT, "RC20/Moduline 300", EMS_DEVICE_FLAG_RC20}, // 0x17 - {93, EMS_DEVICE_TYPE_THERMOSTAT, "RC20RF", EMS_DEVICE_FLAG_RC20}, // 0x18 {67, EMS_DEVICE_TYPE_THERMOSTAT, "RC30", EMS_DEVICE_FLAG_RC30}, // 0x10 {78, EMS_DEVICE_TYPE_THERMOSTAT, "RC30/Moduline 400", EMS_DEVICE_FLAG_RC30}, // 0x10 {86, EMS_DEVICE_TYPE_THERMOSTAT, "RC35", EMS_DEVICE_FLAG_RC35}, // 0x10 + {93, EMS_DEVICE_TYPE_THERMOSTAT, "RC20RF", EMS_DEVICE_FLAG_RC20}, // 0x18 {158, EMS_DEVICE_TYPE_THERMOSTAT, "RC300/RC310/Moduline 3000/Bosch CW400/W-B Sense II", EMS_DEVICE_FLAG_RC300}, // 0x10 {165, EMS_DEVICE_TYPE_THERMOSTAT, "RC100/Moduline 1010", EMS_DEVICE_FLAG_RC300 | EMS_DEVICE_FLAG_NO_WRITE}, // 0x18, cannot write diff --git a/src/version.h b/src/version.h index 955986cb8..bea92a4f9 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define APP_VERSION "1.9.5b10" +#define APP_VERSION "1.9.5b11" From 5577685d85e6b6170041432f09475e685bdd2904 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 3 Jan 2020 21:19:22 +0100 Subject: [PATCH 5/5] bug fix for processing version when no match found --- src/ems.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ems.cpp b/src/ems.cpp index 17de38bfc..837e6c8c9 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -1711,7 +1711,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) { uint8_t i = 0; uint8_t found_index = 0; bool typeFound = false; - while ((i < _EMS_Devices_max) || (!typeFound)) { + while ((i < _EMS_Devices_max) && (!typeFound)) { if (EMS_Devices[i].product_id == product_id) { // we have a matching product id // now lets see if there is a matching device_id since product_id can be on multiple devices @@ -1721,6 +1721,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) { if ((EMS_Devices_Types[j].device_type == device_type) && (EMS_Devices_Types[j].device_id == device_id)) { typeFound = true; found_index = i; + break; } } }