From 0a95b2c0341affce909ca59c178ef83732a4aef8 Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 3 May 2019 15:07:37 +0200 Subject: [PATCH] more optimizations --- src/ems.cpp | 37 +++++++++++++++++++++++++++++++------ src/ems_devices.h | 7 ++++--- src/test_data.h | 18 +++++++++++++++--- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/src/ems.cpp b/src/ems.cpp index 830a3b3f4..a4ea31da4 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -49,10 +49,16 @@ void _process_UBAMonitorWWMessage(_EMS_RxTelegram * EMS_RxTelegram); void _process_UBAParameterWW(_EMS_RxTelegram * EMS_RxTelegram); void _process_UBATotalUptimeMessage(_EMS_RxTelegram * EMS_RxTelegram); void _process_UBAParametersMessage(_EMS_RxTelegram * EMS_RxTelegram); + void _process_SetPoints(_EMS_RxTelegram * EMS_RxTelegram); + +// SM10 void _process_SM10Monitor(_EMS_RxTelegram * EMS_RxTelegram); + +// SM100 void _process_SM100Monitor(_EMS_RxTelegram * EMS_RxTelegram); void _process_SM100Status(_EMS_RxTelegram * EMS_RxTelegram); +void _process_SM100Status2(_EMS_RxTelegram * EMS_RxTelegram); // Common for most thermostats void _process_RCTime(_EMS_RxTelegram * EMS_RxTelegram); @@ -104,6 +110,7 @@ const _EMS_Type EMS_Types[] = { {EMS_MODEL_OTHER, EMS_TYPE_SM10Monitor, "SM10Monitor", _process_SM10Monitor}, {EMS_MODEL_OTHER, EMS_TYPE_SM100Monitor, "SM100Monitor", _process_SM100Monitor}, {EMS_MODEL_OTHER, EMS_TYPE_SM100Status, "SM100Status", _process_SM100Status}, + {EMS_MODEL_OTHER, EMS_TYPE_SM100Status2, "SM100Status2", _process_SM100Status2}, // RC10 {EMS_MODEL_RC10, EMS_TYPE_RCTime, "RCTime", _process_RCTime}, @@ -831,7 +838,6 @@ void _printMessage(_EMS_RxTelegram * EMS_RxTelegram) { * and then call its callback if there is one defined */ void _ems_processTelegram(_EMS_RxTelegram * EMS_RxTelegram) { - // print out the telegram for verbose mode if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_THERMOSTAT) { _printMessage(EMS_RxTelegram); @@ -843,8 +849,8 @@ void _ems_processTelegram(_EMS_RxTelegram * EMS_RxTelegram) { } // header - uint8_t src = EMS_RxTelegram->src; - uint16_t type = EMS_RxTelegram->type; + uint8_t dest = EMS_RxTelegram->dest; + uint16_t type = EMS_RxTelegram->type; // see if we recognize the type first by scanning our known EMS types list bool typeFound = false; @@ -852,12 +858,19 @@ void _ems_processTelegram(_EMS_RxTelegram * EMS_RxTelegram) { while (i < _EMS_Types_max) { if (EMS_Types[i].type == type) { - // is it common type for everyone? - // is it for us? So the src must match with either the boiler, thermostat or other devices + // is it a broadcast or something sent to us? + // we don't really care where it is from + if ((dest == EMS_ID_NONE) || (dest == EMS_ID_ME)) { + typeFound = true; + break; + } + + /* if ((EMS_Types[i].model_id == EMS_MODEL_ALL) || ((src == EMS_Boiler.device_id) || (src == EMS_Thermostat.device_id) || (src == EMS_ID_SM))) { typeFound = true; break; } + */ } i++; } @@ -868,7 +881,7 @@ void _ems_processTelegram(_EMS_RxTelegram * EMS_RxTelegram) { if ((EMS_Types[i].processType_cb) != (void *)NULL) { // print non-verbose message if ((EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_BASIC) || (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE)) { - myDebug("<--- %s(0x%02X) received", EMS_Types[i].typeString, type); + myDebug("<--- %s(0x%02X)", EMS_Types[i].typeString, type); } // call callback function to process the telegram, only if there is data if (EMS_RxTelegram->emsplus) { @@ -1312,6 +1325,18 @@ void _process_SM100Status(_EMS_RxTelegram * EMS_RxTelegram) { EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT } +/* + * SM100Status2 - type 0x026A EMS+ for pump on/off + */ +void _process_SM100Status2(_EMS_RxTelegram * EMS_RxTelegram) { + if (EMS_RxTelegram->data_length == 1) { + EMS_Other.SMpump = _bitRead(0, 2); // 03=off 04=on + } + + EMS_Other.SM = true; + EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT +} + /** * UBASetPoint 0x1A */ diff --git a/src/ems_devices.h b/src/ems_devices.h index 367601c1e..2e8096280 100644 --- a/src/ems_devices.h +++ b/src/ems_devices.h @@ -44,6 +44,7 @@ #define EMS_TYPE_SM10Monitor 0x97 // SM10Monitor #define EMS_TYPE_SM100Monitor 0x0262 // SM100Monitor #define EMS_TYPE_SM100Status 0x0264 // SM100Status +#define EMS_TYPE_SM100Status2 0x026A // SM100Status2 /* * Thermostats... @@ -124,7 +125,7 @@ typedef enum { EMS_MODEL_BOSCHEASY, EMS_MODEL_RC310, EMS_MODEL_CW100, - EMS_MODEL_RC1010, + EMS_MODEL_1010, EMS_MODEL_OT } _EMS_MODEL_ID; @@ -159,7 +160,7 @@ const _Other_Type Other_Types[] = { {EMS_MODEL_OTHER, 73, EMS_ID_SM, "SM10 Solar Module"}, {EMS_MODEL_OTHER, 163, EMS_ID_SM, "SM100 Solar Module"}, {EMS_MODEL_OTHER, 171, 0x02, "EMS-OT OpenTherm converter"}, - {EMS_MODEL_OTHER, 252, EMS_ID_GATEWAY, "Web Gateway KM200"} // warning, fake product id! + {EMS_MODEL_OTHER, 189, EMS_ID_GATEWAY, "Web Gateway KM200"} }; @@ -178,6 +179,6 @@ const _Thermostat_Type Thermostat_Types[] = { {EMS_MODEL_BOSCHEASY, 206, 0x02, "Bosch Easy", EMS_THERMOSTAT_WRITE_NO}, {EMS_MODEL_RC310, 158, 0x10, "RC300/RC310", EMS_THERMOSTAT_WRITE_NO}, {EMS_MODEL_CW100, 255, 0x18, "Bosch CW100", EMS_THERMOSTAT_WRITE_NO}, - {EMS_MODEL_RC1010, 165, 0x18, "RC1010/Nefit Moduline 1010", EMS_THERMOSTAT_WRITE_NO} + {EMS_MODEL_1010, 165, 0x18, "Nefit Moduline 1010", EMS_THERMOSTAT_WRITE_NO} }; diff --git a/src/test_data.h b/src/test_data.h index ff8fb3e87..e6a2cdece 100644 --- a/src/test_data.h +++ b/src/test_data.h @@ -7,14 +7,14 @@ static const char * TEST_DATA[] = { "10 00 FF 00 01 A5 80 00 01 30 28 00 30 28 01 54 03 03 01 01 54 02 A8 00 00 11 01 03 FF FF 00", // test 2 - RC310 ems+ "10 00 FF 19 01 A5 06 04 00 00 00 00 FF 64 37 00 3C 01 FF 01", // test 3 - RC310 ems+ "30 00 FF 00 02 62 00 A1 01 3F 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00", // test 4 - SM100 - "10 00 FF 00 01 A5 00 D7 21 00 00 00 00 30 01 84 01 01 03 01 84 01 F1 00 00 11 01 00 08 63 00", // test 5 - RC1010 + "10 00 FF 00 01 A5 00 D7 21 00 00 00 00 30 01 84 01 01 03 01 84 01 F1 00 00 11 01 00 08 63 00", // test 5 - Moduline 1010 "18 00 FF 00 01 A5 00 DD 21 23 00 00 23 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00", // test 6 - RC300 "90 00 FF 00 00 6F 01 01 00 46 00 B9", // test 7 - FR10 "30 00 FF 00 02 62 01 FB 01 9E 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 2B", // test 8 - SM100 "30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0C 20 64 00 00 00 00 E9", // test 9 - SM100 "30 09 FF 00 00 01", // test 10 - EMS+ "30 0B 97 00", // test 11 - SM100 - "30 00 FF 00 02 62 1 CA", // test 12 - SM100 + "30 00 FF 00 02 62 01 CA", // test 12 - SM100 "30 00 FF 00 02 8E 00 00 00 00 00 00 05 19 00 00 75 D3", // test 13 - SM100 "30 00 FF 00 02 63 80 00 80 00 00 00 80 00 80 00 80 00 00", // test 14 - SM100 "30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0B 09 64 00 00 00 00", // test 15 - SM100 @@ -22,7 +22,19 @@ static const char * TEST_DATA[] = { "30 00 FF 00 02 6A 03 03 03 00 03 03 03 03 03 00 03 03", // test 17 - SM100 "30 00 FF 00 02 6A 03 03 03 00 03 03 03 03 03 00 04 03", // test 18 - SM100 "30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 09 08 64 00 00 00 00", // test 19 - SM100 - "10 00 FF 07 01 A5 32" // test 20 - RC EMS+ + "10 00 FF 07 01 A5 32", // test 20 - RC EMS+ + "38 10 FF 00 03 2B 00 D1 08 2A 01", // test 21 - heatpump + "38 10 FF 00 03 7B 08 24 00 4B", // test 22 - heatpump + "08 00 FF 31 03 94 00 00 00 00 00 00 00", // test 23 - heatpump + "08 00 FF 00 03 95 00 6D C5 0E 00 05 BA 7C 00 68 0A 92 00 00 00 00 00 00 00 00 00 00 00 CD", // test 24 - heatpump + "08 00 FF 48 03 95 00 00 01 47 00 00 00 00 00 00 00 00", // test 25 - heatpump + "08 00 FF 00 03 A2 10 01 02 02 00", // test 26 - heatpump + "08 00 FF 00 03 A3 00 0B 00 00 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 08 00 00 00 0A", // test 27 - heatpump + "30 00 FF 0A 02 6A 04", // test 28 - SM100 pump on + "30 00 FF 0A 02 6A 03", // test 29 - SM100 pump off + "48 90 02 00 01", // test 30 - version test + "10 48 02 00 9E", // test 31 - version test + "48 88 02 00 0A" // test 32 - version test };