From 0af60a320d5b2c7f9b84924529fed7e5ff57611a Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 3 Jan 2020 11:24:12 +0100 Subject: [PATCH] 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"