mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
Added print messages and got temperature setpoitn working
This commit is contained in:
101
src/ems.cpp
101
src/ems.cpp
@@ -59,6 +59,9 @@ void _process_RC35StatusMessage(uint8_t type, uint8_t * data, uint8_t length);
|
||||
void _process_EasyStatusMessage(uint8_t type, uint8_t * data, uint8_t length);
|
||||
//EMS Plus
|
||||
void _process_EmsPlusStatusMessage(uint8_t type, uint8_t * data, uint8_t length);
|
||||
|
||||
//debug messages
|
||||
void _printMessage(uint8_t * telegram, uint8_t length);
|
||||
/*
|
||||
* Recognized EMS types and the functions they call to process the telegrams
|
||||
* Format: MODEL ID, TYPE ID, Description, function
|
||||
@@ -116,7 +119,7 @@ const _EMS_Type EMS_Types[] = {
|
||||
{EMS_MODEL_EASY, EMS_TYPE_EasyStatusMessage, "EasyStatusMessage", _process_EasyStatusMessage},
|
||||
{EMS_MODEL_BOSCHEASY, EMS_TYPE_EasyStatusMessage, "EasyStatusMessage", _process_EasyStatusMessage},
|
||||
//Ems plus
|
||||
{EMSP_MODEL_RC10, EMS_TYPE_EmsPlusStatusMessage, "EasyStatusMessage", _process_EmsPlusStatusMessage}
|
||||
{EMSP_MODEL_RC10, EMS_TYPE_EmsPlusStatusMessage, "EMSPStatusMessage", _process_EmsPlusStatusMessage}
|
||||
|
||||
|
||||
};
|
||||
@@ -652,7 +655,48 @@ void _ems_processTelegram(uint8_t * telegram, uint8_t length) {
|
||||
uint8_t type = telegram[2];
|
||||
uint8_t offset = telegram[3];
|
||||
uint8_t * data = telegram + 4; // data block starts at position 5
|
||||
_printMessage(telegram, length);
|
||||
|
||||
// see if we recognize the type first by scanning our known EMS types list
|
||||
// trying to match the type ID
|
||||
bool commonType = false;
|
||||
bool typeFound = false;
|
||||
bool forUs = false;
|
||||
int i = 0;
|
||||
|
||||
while (i < _EMS_Types_max) {
|
||||
if (EMS_Types[i].type == type) {
|
||||
typeFound = true;
|
||||
commonType = (EMS_Types[i].model_id == EMS_MODEL_ALL); // is it common type for everyone?
|
||||
forUs = (src == EMS_Boiler.type_id) || (src == EMS_Thermostat.type_id); // is it for us? So the src must match
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// if it's a common type (across ems devices) or something specifically for us process it.
|
||||
// dest will be EMS_ID_NONE and offset 0x00 for a broadcast message
|
||||
if (typeFound && (commonType || forUs)) {
|
||||
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);
|
||||
}
|
||||
// call callback function to process it
|
||||
// as we only handle complete telegrams (not partial) check that the offset is 0
|
||||
if (offset == EMS_ID_NONE) {
|
||||
(void)EMS_Types[i].processType_cb(type, data, length - 5);
|
||||
} else if (type == 255)
|
||||
(void)EMS_Types[i].processType_cb(type, telegram, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
void _printMessage(uint8_t * telegram, uint8_t length) {
|
||||
uint8_t src = telegram[0] & 0x7F;
|
||||
uint8_t dest = telegram[1] & 0x7F; // remove 8th bit to handle both reads and writes
|
||||
uint8_t type = telegram[2];
|
||||
uint8_t offset = telegram[3];
|
||||
uint8_t * data = telegram + 4; // data block starts at position 5
|
||||
// print detailed telegram data
|
||||
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_THERMOSTAT) {
|
||||
char output_str[300] = {0}; // roughly EMS_MAX_TELEGRAM_LENGTH*3 + 20
|
||||
@@ -704,39 +748,6 @@ void _ems_processTelegram(uint8_t * telegram, uint8_t length) {
|
||||
_debugPrintTelegram(output_str, telegram, length, color_s);
|
||||
}
|
||||
}
|
||||
|
||||
// see if we recognize the type first by scanning our known EMS types list
|
||||
// trying to match the type ID
|
||||
bool commonType = false;
|
||||
bool typeFound = false;
|
||||
bool forUs = false;
|
||||
int i = 0;
|
||||
|
||||
while (i < _EMS_Types_max) {
|
||||
if (EMS_Types[i].type == type) {
|
||||
typeFound = true;
|
||||
commonType = (EMS_Types[i].model_id == EMS_MODEL_ALL); // is it common type for everyone?
|
||||
forUs = (src == EMS_Boiler.type_id) || (src == EMS_Thermostat.type_id); // is it for us? So the src must match
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// if it's a common type (across ems devices) or something specifically for us process it.
|
||||
// dest will be EMS_ID_NONE and offset 0x00 for a broadcast message
|
||||
if (typeFound && (commonType || forUs)) {
|
||||
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);
|
||||
}
|
||||
// call callback function to process it
|
||||
// as we only handle complete telegrams (not partial) check that the offset is 0
|
||||
if (offset == EMS_ID_NONE) {
|
||||
(void)EMS_Types[i].processType_cb(type, data, length - 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1040,10 +1051,24 @@ void _process_EasyStatusMessage(uint8_t type, uint8_t * data, uint8_t length) {
|
||||
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
|
||||
}
|
||||
void _process_EmsPlusStatusMessage(uint8_t type, uint8_t * data, uint8_t length) {
|
||||
myDebug("The type is ", type);
|
||||
myDebug("The data is ", data);
|
||||
myDebug("The length is ", length);
|
||||
if (data[3] == 3 || data[3] == 6 || data[3] == 10) {
|
||||
EMS_Thermostat.setpoint_roomTemp = ((float)data[6]) / (float)2;
|
||||
if (true) {
|
||||
char str[300];
|
||||
char buffer[16];
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
strlcat(str, _hextoa(data[i], buffer), sizeof(str));
|
||||
strlcat(str, " ", sizeof(str)); // add space
|
||||
}
|
||||
myDebug(str);
|
||||
}
|
||||
}
|
||||
//EMS_Sys_Status.emsLogging = EMS_SYS_LOGGING_NONE;
|
||||
}
|
||||
/*
|
||||
strlcat(output_str, ", type 0x", sizeof(output_str));
|
||||
strlcat(output_str, _hextoa(type, buffer), sizeof(output_str));
|
||||
*/
|
||||
/**
|
||||
* type 0xB0 - for reading the mode from the RC10 thermostat (0x17)
|
||||
* received only after requested
|
||||
@@ -1822,4 +1847,4 @@ void ems_setWarmTapWaterActivated(bool activated) {
|
||||
}
|
||||
|
||||
EMS_TxQueue.push(EMS_TxTelegram); // add to queue
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@
|
||||
#define EMS_TYPE_EasyStatusMessage_setpoint 10 // setpoint temp
|
||||
#define EMS_TYPE_EasyStatusMessage_curr 8 // current temp
|
||||
// Ems plus
|
||||
#define EMS_TYPE_EmsPlusStatusMessage 0x00 // reading values on an Easy Thermostat
|
||||
#define EMS_TYPE_EmsPlusStatusMessage 0xFF // reading values on an Easy Thermostat
|
||||
#define EMS_TYPE_EmsPlusStatusMessage_setpoint 0 // setpoint temp
|
||||
#define EMS_TYPE_EmsPlusStatusMessage_curr 0 // current temp
|
||||
// Known EMS types
|
||||
@@ -125,7 +125,7 @@ const _Boiler_Type Boiler_Types[] = {
|
||||
{EMS_MODEL_UBA, 125, 0x09, "BC25 Base Controller"},
|
||||
{EMS_MODEL_UBA, 68, 0x09, "RFM20 Receiver"},
|
||||
{EMS_MODEL_UBA, 95, 0x08, "Bosch Condens 2500"},
|
||||
{EMS_MODEL_UBA, 205, 0x02, "Nefit Moduline Easy Connect"},
|
||||
{EMS_MODEL_UBA, 205, 0x08, "Nefit Moduline Easy Connect"},
|
||||
{EMS_MODEL_UBA, 251, 0x21, "MM10 Mixer Module"}, // warning, fake product id!
|
||||
{EMS_MODEL_UBA, 250, 0x11, "WM10 Switch Module"}, // warning, fake product id!
|
||||
};
|
||||
@@ -145,6 +145,5 @@ const _Thermostat_Type Thermostat_Types[] = {
|
||||
{EMS_MODEL_BOSCHEASY, 206, 0x02, "Bosch Easy", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_NO},
|
||||
{EMS_MODEL_RC310, 158, 0x10, "RC310", EMS_THERMOSTAT_READ_NO, EMS_THERMOSTAT_WRITE_NO},
|
||||
{EMS_MODEL_CW100, 255, 0x18, "Bosch CW100", EMS_THERMOSTAT_READ_NO, EMS_THERMOSTAT_WRITE_NO},
|
||||
{EMSP_MODEL_RC10, 165, 0x02, "RC10/Nefit Moduline 1010)", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_YES},
|
||||
|
||||
{EMSP_MODEL_RC10, 165, 0x18, "RC10/Nefit Moduline 1010)", EMS_THERMOSTAT_READ_YES, EMS_THERMOSTAT_WRITE_NO},
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#define TOPIC_SHOWER_COLDSHOT "shower_coldshot" // used to trigger a coldshot from an MQTT command
|
||||
|
||||
// default values for shower logic on/off
|
||||
#define BOILER_SHOWER_TIMER 1 // enable (1) to monitor shower time
|
||||
#define BOILER_SHOWER_TIMER 0 // enable (1) to monitor shower time
|
||||
#define BOILER_SHOWER_ALERT 0 // enable (1) to send alert of cold water when shower time limit has exceeded
|
||||
#define SHOWER_MAX_DURATION 420000 // in ms. 7 minutes, before trigger a shot of cold water
|
||||
|
||||
|
||||
Reference in New Issue
Block a user