mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
seperate boiler detection - #317
This commit is contained in:
74
src/ems.cpp
74
src/ems.cpp
@@ -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) {
|
||||||
@@ -1774,6 +1787,7 @@ 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);
|
||||||
|
|||||||
Reference in New Issue
Block a user