seperate boiler detection - #317

This commit is contained in:
Paul
2020-01-31 00:08:04 +01:00
parent a626f4ece4
commit 5140db5444

View File

@@ -129,10 +129,10 @@ void ems_init() {
EMS_Mixing.hc[i].flowSetTemp = EMS_VALUE_INT_NOTSET; EMS_Mixing.hc[i].flowSetTemp = EMS_VALUE_INT_NOTSET;
} }
for (uint8_t i = 0; i < EMS_THERMOSTAT_MAXWWC; i++) { for (uint8_t i = 0; i < EMS_THERMOSTAT_MAXWWC; i++) {
EMS_Mixing.wwc[i].wwc = i + 1; EMS_Mixing.wwc[i].wwc = i + 1;
EMS_Mixing.wwc[i].flowTemp = EMS_VALUE_USHORT_NOTSET; EMS_Mixing.wwc[i].flowTemp = EMS_VALUE_USHORT_NOTSET;
EMS_Mixing.wwc[i].pumpMod = EMS_VALUE_INT_NOTSET; EMS_Mixing.wwc[i].pumpMod = EMS_VALUE_INT_NOTSET;
EMS_Mixing.wwc[i].tempStatus = EMS_VALUE_INT_NOTSET; EMS_Mixing.wwc[i].tempStatus = EMS_VALUE_INT_NOTSET;
} }
// UBAParameterWW // UBAParameterWW
@@ -862,9 +862,9 @@ void ems_parseTelegram(uint8_t * telegram, uint8_t length) {
_debugPrintTelegram("", &EMS_RxTelegram, COLOR_WHITE, true); _debugPrintTelegram("", &EMS_RxTelegram, COLOR_WHITE, true);
} else if ((EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_WATCH) && (EMS_RxTelegram.type == EMS_Sys_Status.emsLogging_ID)) { } else if ((EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_WATCH) && (EMS_RxTelegram.type == EMS_Sys_Status.emsLogging_ID)) {
_debugPrintTelegram("", &EMS_RxTelegram, COLOR_WHITE, true); _debugPrintTelegram("", &EMS_RxTelegram, COLOR_WHITE, true);
// raw printout for log d [id] disabled, moved to _printMessage() // raw printout for log d [id] disabled, moved to _printMessage()
// } else if ((EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_DEVICE) && ((EMS_RxTelegram.src == EMS_Sys_Status.emsLogging_ID) || (EMS_RxTelegram.dest == EMS_Sys_Status.emsLogging_ID))) { // } else if ((EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_DEVICE) && ((EMS_RxTelegram.src == EMS_Sys_Status.emsLogging_ID) || (EMS_RxTelegram.dest == EMS_Sys_Status.emsLogging_ID))) {
// _debugPrintTelegram("", &EMS_RxTelegram, COLOR_WHITE, true); // _debugPrintTelegram("", &EMS_RxTelegram, COLOR_WHITE, true);
} }
// Assume at this point we have something that vaguely resembles a telegram in the format [src] [dest] [type] [offset] [data] [crc] // Assume at this point we have something that vaguely resembles a telegram in the format [src] [dest] [type] [offset] [data] [crc]
@@ -943,7 +943,7 @@ void _printMessage(_EMS_RxTelegram * EMS_RxTelegram) {
_debugPrintTelegram(output_str, EMS_RxTelegram, color_s); _debugPrintTelegram(output_str, EMS_RxTelegram, color_s);
} }
} else if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_DEVICE) { } else if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_DEVICE) {
// only print ones to/from DeviceID // only print ones to/from DeviceID
if ((src == EMS_Sys_Status.emsLogging_ID) || (dest == EMS_Sys_Status.emsLogging_ID)) { if ((src == EMS_Sys_Status.emsLogging_ID) || (dest == EMS_Sys_Status.emsLogging_ID)) {
_debugPrintTelegram(output_str, EMS_RxTelegram, color_s); _debugPrintTelegram(output_str, EMS_RxTelegram, color_s);
} }
@@ -1057,8 +1057,8 @@ void ems_setWarmWaterCirculation(bool activated) {
EMS_TxTelegram.type = EMS_TYPE_UBAFlags; EMS_TxTelegram.type = EMS_TYPE_UBAFlags;
EMS_TxTelegram.offset = EMS_OFFSET_UBAParameterWW_wwCirulation; EMS_TxTelegram.offset = EMS_OFFSET_UBAParameterWW_wwCirulation;
EMS_TxTelegram.length = EMS_MIN_TELEGRAM_LENGTH; EMS_TxTelegram.length = EMS_MIN_TELEGRAM_LENGTH;
EMS_TxTelegram.type_validate = EMS_ID_NONE; // don't validate EMS_TxTelegram.type_validate = EMS_ID_NONE; // don't validate
EMS_TxTelegram.dataValue = (activated ? 0x22 : 0x02); EMS_TxTelegram.dataValue = (activated ? 0x22 : 0x02);
EMS_TxQueue.push(EMS_TxTelegram); EMS_TxQueue.push(EMS_TxTelegram);
} }
@@ -1303,7 +1303,7 @@ void _process_MMPLUSStatusMessageWW(_EMS_RxTelegram * EMS_RxTelegram) {
// Mixer - 0xAB // Mixer - 0xAB
void _process_MMStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) { void _process_MMStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
uint8_t hc = 1; // fixed, for 0xAB uint8_t hc = 0; // fixed, for 0xAB only
EMS_Mixing.hc[hc].active = true; EMS_Mixing.hc[hc].active = true;
_setValue(EMS_RxTelegram, &EMS_Mixing.hc[hc].flowTemp, EMS_OFFSET_MMStatusMessage_flow_temp); _setValue(EMS_RxTelegram, &EMS_Mixing.hc[hc].flowTemp, EMS_OFFSET_MMStatusMessage_flow_temp);
@@ -1662,7 +1662,7 @@ void ems_clearDeviceList() {
* add an EMS device to our list of detected devices if its unique * add an EMS device to our list of detected devices if its unique
* returns true if already in list * returns true if already in list
*/ */
bool _addDevice(_EMS_DEVICE_TYPE device_type, uint8_t product_id, uint8_t device_id, const char * device_desc_p, const char * version) { bool _addDevice(_EMS_DEVICE_TYPE device_type, uint8_t product_id, uint8_t device_id, const char * device_desc_p, const char * version, uint8_t brand) {
_Detected_Device device; _Detected_Device device;
// check for duplicates // check for duplicates
@@ -1685,6 +1685,20 @@ bool _addDevice(_EMS_DEVICE_TYPE device_type, uint8_t product_id, uint8_t device
char line[500]; char line[500];
strlcpy(line, "New EMS device recognized as a ", sizeof(line)); strlcpy(line, "New EMS device recognized as a ", sizeof(line));
if (brand == 1) {
strlcat(line, "Bosch ", sizeof(line));
} else if (brand == 2) {
strlcat(line, "Junkers ", sizeof(line));
} else if (brand == 3) {
strlcat(line, "Buderus ", sizeof(line));
} else if (brand == 4) {
strlcat(line, "Nefit ", sizeof(line));
} else if (brand == 5) {
strlcat(line, "Sieger ", sizeof(line));
} else if (brand == 11) {
strlcat(line, "Worcester ", sizeof(line));
}
// get type as a string // get type as a string
char type_s[50]; char type_s[50];
if (ems_getDeviceTypeName(device_type, type_s)) { if (ems_getDeviceTypeName(device_type, type_s)) {
@@ -1760,10 +1774,9 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
return; return;
} }
uint8_t offset = 0;
// check for 2nd subscriber // check for 2nd subscriber
// e.g. 18 0B 02 00 00 00 00 5E 02 01 // e.g. 18 0B 02 00 00 00 00 5E 02 01
uint8_t offset = 0;
if (EMS_RxTelegram->data[0] == 0x00) { if (EMS_RxTelegram->data[0] == 0x00) {
// see if we have a 2nd subscriber // see if we have a 2nd subscriber
if (EMS_RxTelegram->data[3] != 0x00) { if (EMS_RxTelegram->data[3] != 0x00) {
@@ -1773,7 +1786,8 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
} }
} }
uint8_t device_id = EMS_RxTelegram->src; // device ID uint8_t device_id = EMS_RxTelegram->src; // device ID
uint8_t product_id = EMS_RxTelegram->data[offset]; // product ID
// get version as XX.XX // get version as XX.XX
char version[10] = {0}; char version[10] = {0};
@@ -1782,20 +1796,35 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
strlcat(version, ".", sizeof(version)); strlcat(version, ".", sizeof(version));
strlcat(version, _smallitoa(EMS_RxTelegram->data[offset + 2], buf), sizeof(version)); strlcat(version, _smallitoa(EMS_RxTelegram->data[offset + 2], buf), sizeof(version));
// some devices store the protocol type (HT3, Buderus) in tbe last byte // some devices store the protocol type (HT3, Buderus) in the last byte
// we don't do anything with this yet. // 0=unknown, 1=bosch, 2=junkers, 3=buderus, 4=nefit, 5=sieger, 11=worcester
uint8_t brand;
if (EMS_RxTelegram->data_length >= 10) { if (EMS_RxTelegram->data_length >= 10) {
uint8_t protocol_type = EMS_RxTelegram->data[9]; brand = EMS_RxTelegram->data[9];
if (protocol_type == 2) { } else {
// it's a junkers brand = 0; // unknown
} else if (protocol_type >= 3) {
// it's buderus
}
} }
// scan through known devices matching the productid // first scan through matching boilers, as these are unique to DeviceID 0x08
uint8_t product_id = EMS_RxTelegram->data[offset]; uint8_t i = 0;
uint8_t i = 0; while (i < _EMS_Devices_max) {
if ((EMS_Devices[i].product_id == product_id) && (EMS_Devices[i].type == EMS_DEVICE_TYPE_BOILER) && (device_id == EMS_ID_BOILER)) {
// we have a matching boiler, add it then quit
EMS_Boiler.device_id = EMS_ID_BOILER;
EMS_Boiler.device_flags = EMS_DEVICE_FLAG_NONE;
EMS_Boiler.product_id = product_id;
EMS_Boiler.device_desc_p = EMS_Devices[i].device_desc;
strlcpy(EMS_Boiler.version, version, sizeof(EMS_Boiler.version));
_addDevice(EMS_DEVICE_TYPE_BOILER, product_id, EMS_ID_BOILER, EMS_Devices[i].device_desc, version, brand);
ems_getBoilerValues(); // get Boiler values that we would usually have to wait for
return; // quit
break;
}
i++;
}
// not a boiler
i = 0;
uint8_t found_index = 0; uint8_t found_index = 0;
bool typeFound = false; bool typeFound = false;
while (i < _EMS_Devices_max) { while (i < _EMS_Devices_max) {
@@ -1810,7 +1839,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
// if not found, just add it as an unknown device and exit // if not found, just add it as an unknown device and exit
if (!typeFound) { if (!typeFound) {
(void)_addDevice(EMS_DEVICE_TYPE_UNKNOWN, product_id, device_id, nullptr, version); (void)_addDevice(EMS_DEVICE_TYPE_UNKNOWN, product_id, device_id, nullptr, version, 0);
return; return;
} }
@@ -1818,21 +1847,13 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
_EMS_DEVICE_TYPE type = EMS_Devices[found_index].type; // device type _EMS_DEVICE_TYPE type = EMS_Devices[found_index].type; // device type
// we recognized it, see if we already have it in our recognized list // we recognized it, see if we already have it in our recognized list
if (_addDevice(type, product_id, device_id, device_desc_p, version)) { if (_addDevice(type, product_id, device_id, device_desc_p, version, brand)) {
return; // already in list return; // already in list
} }
uint8_t flags = EMS_Devices[found_index].flags; // it's a new entry, get the specifics uint8_t flags = EMS_Devices[found_index].flags; // it's a new entry, get the specifics
// for a boiler, sometimes we get a device_id of 0x09 with the same product_id, so lets make sure it is the UBA Master if (type == EMS_DEVICE_TYPE_THERMOSTAT) {
if ((type == EMS_DEVICE_TYPE_BOILER) && (device_id == EMS_ID_BOILER)) {
EMS_Boiler.device_id = device_id;
EMS_Boiler.product_id = product_id;
EMS_Boiler.device_flags = flags;
EMS_Boiler.device_desc_p = device_desc_p;
strlcpy(EMS_Boiler.version, version, sizeof(EMS_Boiler.version));
ems_getBoilerValues(); // get Boiler values that we would usually have to wait for
} else if (type == EMS_DEVICE_TYPE_THERMOSTAT) {
// we can only support a single thermostat currently, so check which product_id we may have chosen // we can only support a single thermostat currently, so check which product_id we may have chosen
// to be the master - see https://github.com/proddy/EMS-ESP/issues/238 // to be the master - see https://github.com/proddy/EMS-ESP/issues/238
if ((EMS_Sys_Status.emsMasterThermostat == 0) || (EMS_Sys_Status.emsMasterThermostat == product_id)) { if ((EMS_Sys_Status.emsMasterThermostat == 0) || (EMS_Sys_Status.emsMasterThermostat == product_id)) {
@@ -2899,8 +2920,7 @@ const _EMS_Type EMS_Types[] = {
{EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMPLUSStatusMessage_HC4, "MMPLUSStatusMessage_HC4", _process_MMPLUSStatusMessage}, {EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMPLUSStatusMessage_HC4, "MMPLUSStatusMessage_HC4", _process_MMPLUSStatusMessage},
{EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMPLUSStatusMessage_WWC1, "MMPLUSStatusMessage_WWC1", _process_MMPLUSStatusMessageWW}, {EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMPLUSStatusMessage_WWC1, "MMPLUSStatusMessage_WWC1", _process_MMPLUSStatusMessageWW},
{EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMPLUSStatusMessage_WWC2, "MMPLUSStatusMessage_WWC2", _process_MMPLUSStatusMessageWW}, {EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMPLUSStatusMessage_WWC2, "MMPLUSStatusMessage_WWC2", _process_MMPLUSStatusMessageWW},
{EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMStatusMessage, "MMStatusMessage", _process_MMStatusMessage} {EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMStatusMessage, "MMStatusMessage", _process_MMStatusMessage}};
};
// calculate sizes of arrays at compile time // calculate sizes of arrays at compile time
uint8_t _EMS_Types_max = ArraySize(EMS_Types); uint8_t _EMS_Types_max = ArraySize(EMS_Types);