mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
Merge pull request #20 from Bonusbartus/master
made some changes to make detecting tapwater active easier. might also make the gas calculation possible?
This commit is contained in:
@@ -238,6 +238,19 @@ void _renderIntValue(const char * prefix, const char * postfix, uint8_t value) {
|
||||
myDebug("\n");
|
||||
}
|
||||
|
||||
// takes an int value at prints it to debug log
|
||||
void _renderIntfractionalValue(const char * prefix, const char * postfix, uint8_t value, uint8_t decimals) {
|
||||
myDebug(" %s: ", prefix);
|
||||
char s[20];
|
||||
myDebug("%s.", _int_to_char(s, value/(decimals*10)));
|
||||
myDebug("%s", _int_to_char(s, value%(decimals*10)));
|
||||
if (postfix != NULL) {
|
||||
myDebug(" %s", postfix);
|
||||
}
|
||||
|
||||
myDebug("\n");
|
||||
}
|
||||
|
||||
// takes a bool value at prints it to debug log
|
||||
void _renderBoolValue(const char * prefix, uint8_t value) {
|
||||
myDebug(" %s: ", prefix);
|
||||
@@ -286,11 +299,13 @@ void showInfo() {
|
||||
// UBAParameterWW
|
||||
_renderBoolValue("Warm Water activated", EMS_Boiler.wWActivated);
|
||||
_renderBoolValue("Warm Water circulation pump available", EMS_Boiler.wWCircPump);
|
||||
myDebug(" Warm Water is set to %s\n", (EMS_Boiler.wWComfort ? "Comfort" : "ECO"));
|
||||
_renderIntValue("Warm Water selected temperature", "C", EMS_Boiler.wWSelTemp);
|
||||
_renderIntValue("Warm Water desired temperature", "C", EMS_Boiler.wWDesiredTemp);
|
||||
|
||||
// UBAMonitorWWMessage
|
||||
_renderFloatValue("Warm Water current temperature", "C", EMS_Boiler.wWCurTmp);
|
||||
_renderIntfractionalValue("Warm Water current tapwater flow", "l/min", EMS_Boiler.wWCurFlow, 1);
|
||||
_renderIntValue("Warm Water # starts", "times", EMS_Boiler.wWStarts);
|
||||
myDebug(" Warm Water active time: %d days %d hours %d minutes\n",
|
||||
EMS_Boiler.wWWorkM / 1440,
|
||||
@@ -311,6 +326,7 @@ void showInfo() {
|
||||
_renderIntValue("Burner current power", "%", EMS_Boiler.curBurnPow);
|
||||
_renderFloatValue("Flame current", "uA", EMS_Boiler.flameCurr);
|
||||
_renderFloatValue("System pressure", "bar", EMS_Boiler.sysPress);
|
||||
myDebug(" Current System Service Code: %c%c \n", EMS_Boiler.serviceCodeChar1, EMS_Boiler.serviceCodeChar2);
|
||||
|
||||
// UBAMonitorSlow
|
||||
_renderFloatValue("Outside temperature", "C", EMS_Boiler.extTemp);
|
||||
@@ -381,7 +397,12 @@ void publishValues(bool force) {
|
||||
|
||||
rootBoiler["wWSelTemp"] = _int_to_char(s, EMS_Boiler.wWSelTemp);
|
||||
rootBoiler["wWActivated"] = _bool_to_char(s, EMS_Boiler.wWActivated);
|
||||
sprintf(s, "%s", (EMS_Boiler.wWComfort ? "Comfort" : "ECO"));
|
||||
rootBoiler["wWComfort"] = s;
|
||||
rootBoiler["wWCurTmp"] = _float_to_char(s, EMS_Boiler.wWCurTmp);
|
||||
|
||||
sprintf(s, "%i.%i", EMS_Boiler.wWCurFlow/10, EMS_Boiler.wWCurFlow%10);
|
||||
rootBoiler["wWCurFlow"] = s;
|
||||
rootBoiler["wWHeat"] = _bool_to_char(s, EMS_Boiler.wWHeat);
|
||||
rootBoiler["curFlowTemp"] = _float_to_char(s, EMS_Boiler.curFlowTemp);
|
||||
rootBoiler["retTemp"] = _float_to_char(s, EMS_Boiler.retTemp);
|
||||
@@ -395,6 +416,8 @@ void publishValues(bool force) {
|
||||
rootBoiler["sysPress"] = _float_to_char(s, EMS_Boiler.sysPress);
|
||||
rootBoiler["boilTemp"] = _float_to_char(s, EMS_Boiler.boilTemp);
|
||||
rootBoiler["pumpMod"] = _int_to_char(s, EMS_Boiler.pumpMod);
|
||||
sprintf(s, "%c%c", EMS_Boiler.serviceCodeChar1, EMS_Boiler.serviceCodeChar2);
|
||||
rootBoiler["ServiceCode"] = s;
|
||||
|
||||
size_t len = rootBoiler.measureLength();
|
||||
rootBoiler.printTo(data, len + 1); // form the json string
|
||||
|
||||
30
src/ems.cpp
30
src/ems.cpp
@@ -161,6 +161,7 @@ void ems_init() {
|
||||
EMS_Boiler.wWSelTemp = EMS_VALUE_INT_NOTSET; // Warm Water selected temperature
|
||||
EMS_Boiler.wWCircPump = EMS_VALUE_INT_NOTSET; // Warm Water circulation pump available
|
||||
EMS_Boiler.wWDesiredTemp = EMS_VALUE_INT_NOTSET; // Warm Water desired temperature to prevent infection
|
||||
EMS_Boiler.wWComfort = EMS_VALUE_INT_NOTSET;
|
||||
|
||||
// UBAMonitorFast
|
||||
EMS_Boiler.selFlowTemp = EMS_VALUE_INT_NOTSET; // Selected flow temperature
|
||||
@@ -176,6 +177,8 @@ void ems_init() {
|
||||
EMS_Boiler.curBurnPow = EMS_VALUE_INT_NOTSET; // Burner current power
|
||||
EMS_Boiler.flameCurr = EMS_VALUE_FLOAT_NOTSET; // Flame current in micro amps
|
||||
EMS_Boiler.sysPress = EMS_VALUE_FLOAT_NOTSET; // System pressure
|
||||
EMS_Boiler.serviceCodeChar1 = EMS_VALUE_INT_NOTSET; //
|
||||
EMS_Boiler.serviceCodeChar2 = EMS_VALUE_INT_NOTSET; //
|
||||
|
||||
// UBAMonitorSlow
|
||||
EMS_Boiler.extTemp = EMS_VALUE_FLOAT_NOTSET; // Outside temperature
|
||||
@@ -190,6 +193,7 @@ void ems_init() {
|
||||
EMS_Boiler.wWStarts = EMS_VALUE_INT_NOTSET; // Warm Water # starts
|
||||
EMS_Boiler.wWWorkM = EMS_VALUE_INT_NOTSET; // Warm Water # minutes
|
||||
EMS_Boiler.wWOneTime = EMS_VALUE_INT_NOTSET; // Warm Water one time function on/off
|
||||
EMS_Boiler.wWCurFlow = EMS_VALUE_INT_NOTSET;
|
||||
|
||||
EMS_Boiler.tapwaterActive = EMS_VALUE_INT_NOTSET; // Hot tap water is on/off
|
||||
EMS_Boiler.heatingActive = EMS_VALUE_INT_NOTSET; // Central heating is on/off
|
||||
@@ -723,8 +727,8 @@ void _processType(uint8_t * telegram, uint8_t length) {
|
||||
bool _checkActive() {
|
||||
// hot tap water
|
||||
EMS_Boiler.tapwaterActive =
|
||||
((EMS_Boiler.selFlowTemp == 0)
|
||||
&& (EMS_Boiler.selBurnPow >= EMS_BOILER_BURNPOWER_TAPWATER) & (EMS_Boiler.burnGas == EMS_VALUE_INT_ON));
|
||||
((EMS_Boiler.wWCurFlow != 0) //this is easier
|
||||
&& (EMS_Boiler.burnGas == EMS_VALUE_INT_ON));
|
||||
|
||||
// heating
|
||||
EMS_Boiler.heatingActive =
|
||||
@@ -740,6 +744,7 @@ void _process_UBAParameterWW(uint8_t * data, uint8_t length) {
|
||||
EMS_Boiler.wWSelTemp = data[2];
|
||||
EMS_Boiler.wWCircPump = (data[6] == 0xFF); // 0xFF means on
|
||||
EMS_Boiler.wWDesiredTemp = data[8];
|
||||
EMS_Boiler.wWComfort = (data[EMS_OFFSET_UBAParameterWW_wwComfort] == 0x00);
|
||||
|
||||
// when we receieve this, lets force an MQTT publish
|
||||
EMS_Sys_Status.emsRefreshed = true;
|
||||
@@ -754,6 +759,7 @@ void _process_UBAMonitorWWMessage(uint8_t * data, uint8_t length) {
|
||||
EMS_Boiler.wWStarts = _toLong(13, data);
|
||||
EMS_Boiler.wWWorkM = _toLong(10, data);
|
||||
EMS_Boiler.wWOneTime = bitRead(data[5], 1);
|
||||
EMS_Boiler.wWCurFlow = data[9];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -778,6 +784,10 @@ void _process_UBAMonitorFast(uint8_t * data, uint8_t length) {
|
||||
|
||||
EMS_Boiler.flameCurr = _toFloat(15, data);
|
||||
|
||||
//read the service code / installation status as appears on the display
|
||||
EMS_Boiler.serviceCodeChar1 = data[18]; //ascii character 1
|
||||
EMS_Boiler.serviceCodeChar2 = data[19]; //ascii character 2
|
||||
|
||||
if (data[17] == 0xFF) { // missing value for system pressure
|
||||
EMS_Boiler.sysPress = 0;
|
||||
} else {
|
||||
@@ -1187,7 +1197,7 @@ void ems_setThermostatMode(uint8_t mode) {
|
||||
*/
|
||||
void ems_setWarmWaterTemp(uint8_t temperature) {
|
||||
// check for invalid temp values
|
||||
if ((temperature < 30) || (temperature > 90)) {
|
||||
if ((temperature < 30) || (temperature > EMS_BOILER_TAPWATER_TEMPERATURE_MAX)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1230,6 +1240,20 @@ void ems_setWarmWaterActivated(bool activated) {
|
||||
EMS_TxQueue.push(EMS_TxTelegram);
|
||||
}
|
||||
|
||||
void ems_setWarmWaterModeComfort(bool comfort) {
|
||||
myDebug("Setting boiler warm water to comfort mode %s\n", comfort ? "Comfort" : "Eco");
|
||||
|
||||
_EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
|
||||
|
||||
EMS_TxTelegram.action = EMS_TX_TELEGRAM_WRITE;
|
||||
EMS_TxTelegram.dest = EMS_ID_BOILER;
|
||||
EMS_TxTelegram.type = EMS_TYPE_UBAParameterWW;
|
||||
EMS_TxTelegram.offset = EMS_OFFSET_UBAParameterWW_wwComfort;
|
||||
EMS_TxTelegram.length = EMS_MIN_TELEGRAM_LENGTH;
|
||||
EMS_TxTelegram.type_validate = EMS_ID_NONE; // don't validate
|
||||
EMS_TxTelegram.dataValue = (comfort ? EMS_VALUE_UBAParameterWW_wwComfort_Comfort : EMS_VALUE_UBAParameterWW_wwComfort_Eco); // 0x00 is on, 0xD8 is off
|
||||
EMS_TxQueue.push(EMS_TxTelegram);
|
||||
}
|
||||
/**
|
||||
* Activate / De-activate the Warm Tap Water
|
||||
* true = on, false = off
|
||||
|
||||
35
src/ems.h
35
src/ems.h
@@ -44,6 +44,10 @@
|
||||
#define EMS_OFFSET_UBAParameterWW_wwtemp 2 // WW Temperature
|
||||
#define EMS_OFFSET_UBAParameterWW_wwactivated 1 // WW Activated
|
||||
|
||||
#define EMS_OFFSET_UBAParameterWW_wwComfort 9 // WW is in comfort or eco mode
|
||||
#define EMS_VALUE_UBAParameterWW_wwComfort_Comfort 0x00 // the value for comfort
|
||||
#define EMS_VALUE_UBAParameterWW_wwComfort_Eco 0xD8 // the value for eco
|
||||
|
||||
/*
|
||||
* Thermostat...
|
||||
*/
|
||||
@@ -160,21 +164,24 @@ typedef struct { // UBAParameterWW
|
||||
uint8_t wWSelTemp; // Warm Water selected temperature
|
||||
uint8_t wWCircPump; // Warm Water circulation pump Available
|
||||
uint8_t wWDesiredTemp; // Warm Water desired temperature
|
||||
uint8_t wWComfort; // Warm water comfort or ECO mode
|
||||
|
||||
// UBAMonitorFast
|
||||
uint8_t selFlowTemp; // Selected flow temperature
|
||||
float curFlowTemp; // Current flow temperature
|
||||
float retTemp; // Return temperature
|
||||
uint8_t burnGas; // Gas on/off
|
||||
uint8_t fanWork; // Fan on/off
|
||||
uint8_t ignWork; // Ignition on/off
|
||||
uint8_t heatPmp; // Circulating pump on/off
|
||||
uint8_t wWHeat; // 3-way valve on WW
|
||||
uint8_t wWCirc; // Circulation on/off
|
||||
uint8_t selBurnPow; // Burner max power
|
||||
uint8_t curBurnPow; // Burner current power
|
||||
float flameCurr; // Flame current in micro amps
|
||||
float sysPress; // System pressure
|
||||
uint8_t selFlowTemp; // Selected flow temperature
|
||||
float curFlowTemp; // Current flow temperature
|
||||
float retTemp; // Return temperature
|
||||
uint8_t burnGas; // Gas on/off
|
||||
uint8_t fanWork; // Fan on/off
|
||||
uint8_t ignWork; // Ignition on/off
|
||||
uint8_t heatPmp; // Circulating pump on/off
|
||||
uint8_t wWHeat; // 3-way valve on WW
|
||||
uint8_t wWCirc; // Circulation on/off
|
||||
uint8_t selBurnPow; // Burner max power
|
||||
uint8_t curBurnPow; // Burner current power
|
||||
float flameCurr; // Flame current in micro amps
|
||||
float sysPress; // System pressure
|
||||
uint8_t serviceCodeChar1; // First Character in status/service code
|
||||
uint8_t serviceCodeChar2; // Second Character in status/service code
|
||||
|
||||
// UBAMonitorSlow
|
||||
float extTemp; // Outside temperature
|
||||
@@ -189,6 +196,7 @@ typedef struct { // UBAParameterWW
|
||||
uint32_t wWStarts; // Warm Water # starts
|
||||
uint32_t wWWorkM; // Warm Water # minutes
|
||||
uint8_t wWOneTime; // Warm Water one time function on/off
|
||||
uint8_t wWCurFlow; // Warm Water current flow in l/min
|
||||
|
||||
// calculated values
|
||||
uint8_t tapwaterActive; // Hot tap water is on/off
|
||||
@@ -250,6 +258,7 @@ void ems_setThermostatTemp(float temp);
|
||||
void ems_setThermostatMode(uint8_t mode);
|
||||
void ems_setWarmWaterTemp(uint8_t temperature);
|
||||
void ems_setWarmWaterActivated(bool activated);
|
||||
void ems_setWarmWaterModeComfort(bool comfort);
|
||||
void ems_setWarmTapWaterActivated(bool activated);
|
||||
void ems_setExperimental(uint8_t value);
|
||||
void ems_setPoll(bool b);
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
#define EMS_BOILER_BURNPOWER_TAPWATER 100
|
||||
#define EMS_BOILER_SELFLOWTEMP_HEATING 70
|
||||
|
||||
//define maximum settable tapwater temperature, not every installation supports 90 degrees
|
||||
#define EMS_BOILER_TAPWATER_TEMPERATURE_MAX 60
|
||||
|
||||
// if using the shower timer, change these settings
|
||||
#define SHOWER_PAUSE_TIME 15000 // in ms. 15 seconds, max time if water is switched off & on during a shower
|
||||
#define SHOWER_MIN_DURATION 120000 // in ms. 2 minutes, before recognizing its a shower
|
||||
|
||||
Reference in New Issue
Block a user