Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
2.0.0b11 - with flow/max/min boiler temps - #59
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Jul 31, 2020
1 parent 09895bb commit 163fbba
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 10 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ boiler
wwonetime <on | off>
wwtemp <degrees>
read <type ID>
temp <degrees>
maxpower <%>
minpower <%>
thermostat
set
Expand Down
101 changes: 94 additions & 7 deletions src/devices/boiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ MAKE_PSTR_WORD(comfort)
MAKE_PSTR_WORD(eco)
MAKE_PSTR_WORD(intelligent)
MAKE_PSTR_WORD(hot)
MAKE_PSTR_WORD(maxpower)
MAKE_PSTR_WORD(minpower)
MAKE_PSTR_WORD(temp)

MAKE_PSTR(comfort_mandatory, "<hot | eco | intelligent>")

Expand Down Expand Up @@ -133,6 +136,33 @@ void Boiler::boiler_cmd(const char * message) {
}
return;
}

// boiler temp setting
if (strcmp(command, "temp") == 0) {
uint8_t t = doc["data"];
if (t) {
set_temp(t);
}
return;
}

// boiler max power setting
if (strcmp(command, "maxpower") == 0) {
uint8_t p = doc["data"];
if (p) {
set_max_power(p);
}
return;
}

// boiler min power setting
if (strcmp(command, "minpower") == 0) {
uint8_t p = doc["data"];
if (p) {
set_min_power(p);
}
return;
}
}

void Boiler::boiler_cmd_wwactivated(const char * message) {
Expand Down Expand Up @@ -186,7 +216,7 @@ void Boiler::device_info(JsonArray & root) {

// publish values via MQTT
void Boiler::publish_values() {
const size_t capacity = JSON_OBJECT_SIZE(47); // must recalculate if more objects addded https://arduinojson.org/v6/assistant/
const size_t capacity = JSON_OBJECT_SIZE(50); // must recalculate if more objects addded https://arduinojson.org/v6/assistant/
DynamicJsonDocument doc(capacity);

char s[10]; // for formatting strings
Expand Down Expand Up @@ -337,6 +367,16 @@ void Boiler::publish_values() {
doc["heatWorkMin"] = heatWorkMin_;
}

if (Helpers::hasValue(temp_)) {
doc["heatWorkMin"] = temp_;
}
if (Helpers::hasValue(maxpower_)) {
doc["heatWorkMin"] = maxpower_;
}
if (Helpers::hasValue(setpointpower_)) {
doc["heatWorkMin"] = setpointpower_;
}

if (Helpers::hasValue(serviceCode_)) {
doc["serviceCode"] = serviceCodeChar_;
doc["serviceCodeNumber"] = serviceCode_;
Expand Down Expand Up @@ -435,6 +475,11 @@ void Boiler::show_values(uuid::console::Shell & shell) {
print_value(shell, 2, F("Boiler circuit pump modulation max power"), pump_mod_max_, F_(percent));
print_value(shell, 2, F("Boiler circuit pump modulation min power"), pump_mod_min_, F_(percent));

// UBASetPoint - these may differ from the above
print_value(shell, 2, F("Boiler temp"), temp_, F_(degrees));
print_value(shell, 2, F("Max output power"), maxpower_, F_(percent));
print_value(shell, 2, F("Set power"), setpointpower_, F_(percent));

// UBAMonitorSlow
if (Helpers::hasValue(extTemp_)) {
print_value(shell, 2, F("Outside temperature"), extTemp_, F_(degrees), 10);
Expand Down Expand Up @@ -670,16 +715,16 @@ void Boiler::process_UBAOutdoorTemp(std::shared_ptr<const Telegram> telegram) {
telegram->read_value(extTemp_, 0);
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

// UBASetPoint 0x1A
// not yet implemented
void Boiler::process_UBASetPoints(std::shared_ptr<const Telegram> telegram) {
// uint8_t setpoint = telegram->message_data[0]; // boiler flow temp
// uint8_t ww_power = telegram->message_data[2]; // power in %
telegram->read_value(temp_, 0); // boiler flow temp
telegram->read_value(maxpower_, 1); // max output power in %
telegram->read_value(setpointpower_, 14); // ww pump speed/power?
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

// 0x35
// not yet implemented
void Boiler::process_UBAFlags(std::shared_ptr<const Telegram> telegram) {
Expand Down Expand Up @@ -721,6 +766,24 @@ void Boiler::set_flow_temp(const uint8_t temperature) {
write_command(EMS_TYPE_UBASetPoints, 0, temperature);
}

// set heating temp
void Boiler::set_temp(const uint8_t temperature) {
LOG_INFO(F("Setting boiler temperature to %d C"), temperature);
write_command(EMS_TYPE_UBAParameters, 1, temperature);
}

// set min boiler output
void Boiler::set_min_power(const uint8_t power) {
LOG_INFO(F("Setting boiler min power to "), power);
write_command(EMS_TYPE_UBAParameters, 3, power);
}

// set max temp
void Boiler::set_max_power(const uint8_t power) {
LOG_INFO(F("Setting boiler max power to %d C"), power);
write_command(EMS_TYPE_UBAParameters, 2, power);
}

// 1=hot, 2=eco, 3=intelligent
// note some boilers do not have this setting, than it's done by thermostat
// on a RC35 it's by EMSESP::send_write_request(0x37, 0x10, 2, &set, 1, 0); (set is 1,2,3)
Expand Down Expand Up @@ -825,6 +888,30 @@ void Boiler::console_commands(Shell & shell, unsigned int context) {
set_flow_temp(Helpers::atoint(arguments.front().c_str()));
});

EMSESPShell::commands->add_command(ShellContext::BOILER,
CommandFlags::ADMIN,
flash_string_vector{F_(temp)},
flash_string_vector{F_(degrees_mandatory)},
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
set_temp(Helpers::atoint(arguments.front().c_str()));
});

EMSESPShell::commands->add_command(ShellContext::BOILER,
CommandFlags::ADMIN,
flash_string_vector{F_(maxpower)},
flash_string_vector{F_(n_mandatory)},
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
set_max_power(Helpers::atoint(arguments.front().c_str()));
});

EMSESPShell::commands->add_command(ShellContext::BOILER,
CommandFlags::ADMIN,
flash_string_vector{F_(minpower)},
flash_string_vector{F_(n_mandatory)},
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
set_min_power(Helpers::atoint(arguments.front().c_str()));
});

EMSESPShell::commands->add_command(
ShellContext::BOILER,
CommandFlags::ADMIN,
Expand Down
14 changes: 12 additions & 2 deletions src/devices/boiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Boiler : public EMSdevice {
static constexpr uint8_t EMS_TYPE_UBAFunctionTest = 0x1D;
static constexpr uint8_t EMS_TYPE_UBAFlags = 0x35;
static constexpr uint8_t EMS_TYPE_UBASetPoints = 0x1A;
static constexpr uint8_t EMS_TYPE_UBAParameters = 0x16;

static constexpr uint8_t EMS_BOILER_SELFLOWTEMP_HEATING = 20; // was originally 70, changed to 30 for issue #193, then to 20 with issue #344

Expand Down Expand Up @@ -121,10 +122,15 @@ class Boiler : public EMSdevice {
uint8_t pump_mod_max_ = EMS_VALUE_UINT_NOTSET; // Boiler circuit pump modulation max. power %
uint8_t pump_mod_min_ = EMS_VALUE_UINT_NOTSET; // Boiler circuit pump modulation min. power

// UBASetPoint
uint8_t temp_ = EMS_VALUE_UINT_NOTSET; // boiler flow temp
uint8_t maxpower_ = EMS_VALUE_UINT_NOTSET; // max output power in %
uint8_t setpointpower_ = EMS_VALUE_UINT_NOTSET; // ww pump speed/power?

// other internal calculated params
uint8_t tap_water_active_ = EMS_VALUE_BOOL_NOTSET; // Hot tap water is on/off
uint8_t heating_active_ = EMS_VALUE_BOOL_NOTSET; // Central heating is on/off

uint8_t pumpMod2_ = EMS_VALUE_UINT_NOTSET; // heatpump modulation from 0xE3 (heatpumps)
uint8_t pumpMod2_ = EMS_VALUE_UINT_NOTSET; // heatpump modulation from 0xE3 (heatpumps)

void process_UBAParameterWW(std::shared_ptr<const Telegram> telegram);
void process_UBAMonitorFast(std::shared_ptr<const Telegram> telegram);
Expand Down Expand Up @@ -155,6 +161,10 @@ class Boiler : public EMSdevice {
void set_tapwarmwater_activated(const bool activated);
void set_warmwater_onetime(const bool activated);
void set_warmwater_circulation(const bool activated);
void set_temp(const uint8_t temperature);
void set_min_power(const uint8_t power);
void set_max_power(const uint8_t power);


// mqtt callbacks
void boiler_cmd(const char * message);
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define EMSESP_APP_VERSION "2.0.0b10"
#define EMSESP_APP_VERSION "2.0.0b11"

2 comments on commit 163fbba

@MichaelDvP
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is something wrong, reading 0x1A but writing 0x16.

0x1A is a control message from thermostate to boiler, the boiler itself publishes the values by monitor-telegrams. I don't think these values from 0x1A are relevant.
0x16 is the boiler parameter message where we can read an write. (i'm also working on this message for reducing the burner starts and get merge conflicts with this changes).

Is it realy necessary to add these parameters to telnet if you want to reduce the commandset?
Telnet for logging and watching telegrams, mqtt for setting values and web for configuring, if i get you right.

BTW: Also there are some c&p errors like all publishes as doc["heatWorkMin"]

I will send my changes to 0x16 soon and try to resolve the conflicts.

@proddy
Copy link
Collaborator Author

@proddy proddy commented on 163fbba Jul 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thinking about it you're right again. I rushed the implementation. Next time I'll make GitHub branches for major changes and merge when verified.

There's indeed a mixup between the 0x1A and 0x16 values.

The idea is indeed to keep all config in the Web and use the telnet console for tracking to reduce the memory footprint on a ESP8266. If we follow this process then I should remove the device specific commands and replace with a command than simulates the MQTT. Something like 'send '. Thoughts?

I'll be happy if you can fix this. I guess we remove the UBASetPoint and stick to 0x16 for reading/writing values. I will also start on the mqtt/command refactor and create a new Issue for this.

Please sign in to comment.