add wWSetTemp to boiller mqtt, add wwmode to thermostat

This commit is contained in:
MichaelDvP
2020-06-27 14:42:30 +02:00
parent 4b06a6dd13
commit 55da8a77d2
3 changed files with 67 additions and 5 deletions

View File

@@ -177,6 +177,9 @@ void Boiler::publish_values() {
if (Helpers::hasValue(wWSelTemp_)) {
doc["wWSelTemp"] = wWSelTemp_;
}
if (Helpers::hasValue(wWSetTmp_)) {
doc["wWSetTemp"] = wWSetTmp_;
}
if (Helpers::hasValue(wWDisinfectTemp_)) {
doc["wWDisinfectionTemp"] = wWDisinfectTemp_;
}
@@ -696,20 +699,21 @@ void Boiler::set_warmwater_mode(const uint8_t comfort) {
uint8_t set;
if (comfort == 1) {
LOG_INFO(F("Setting boiler warm water to hot"));
set = 1;
set = 0;
} else if (comfort == 2) {
LOG_INFO(F("Setting boiler warm water to eco"));
set = 0;
set = 0xD8;
} else if (comfort == 3) {
LOG_INFO(F("Setting boiler warm water to intelligent"));
set = 2;
set = 0xEC;
} else {
return; // do nothing
}
write_command(EMS_TYPE_UBAParameterWW, 9, comfort);
write_command(EMS_TYPE_UBAParameterWW, 9, set);
// some boilers do not have this setting, than it's done by thermostat
// Test for RC35, but not a good way, we are here in boiler context.
// EMSESP::send_write_request(0x37, 0x10, 2, &set, 1, 0); // for RC35, maybe work also on RC300
}
// turn on/off warm water

View File

@@ -58,6 +58,7 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i
register_telegram_type(set_typeids[i], F("RC35Set"), false, std::bind(&Thermostat::process_RC35Set, this, _1));
}
register_telegram_type(EMS_TYPE_IBASettings, F("IBASettings"), true, std::bind(&Thermostat::process_IBASettings, this, _1));
register_telegram_type(EMS_TYPE_wwSettings, F("WWSettings"), true, std::bind(&Thermostat::process_RC35wwSettings, this, _1));
// RC20
} else if (flags == EMSdevice::EMS_DEVICE_FLAG_RC20) {
@@ -282,6 +283,10 @@ void Thermostat::thermostat_cmd(const char * message) {
set_control(ctrl, hc_num);
}
}
if (nullptr != doc["wwmode"]) {
std::string mode = doc["wwmode"];
set_ww_mode(mode);
}
if (float ct = doc["calinttemp"]) {
set_settings_calinttemp((int8_t)(ct * 10));
}
@@ -1039,6 +1044,11 @@ void Thermostat::process_IBASettings(std::shared_ptr<const Telegram> telegram) {
telegram->read_value(ibaClockOffset_, 12); // offset (in sec) to clock, 0xff = -1 s, 0x02 = 2 s
}
// Settings WW 0x37 - RC35
void Thermostat::process_RC35wwSettings(std::shared_ptr<const Telegram> telegram) {
telegram->read_value(wwMode_, 2); // 0 off, 1-on, 2-auto
}
// type 0x6F - FR10/FR50/FR100 Junkers
void Thermostat::process_JunkersMonitor(std::shared_ptr<const Telegram> telegram) {
// ignore single byte telegram messages
@@ -1263,6 +1273,28 @@ void Thermostat::set_control(const uint8_t ctrl, const uint8_t hc_num) {
}
}
// Set the WW mode in 0x37, 0-off, 1-on, 2-auto
void Thermostat::set_ww_mode(const uint8_t mode) {
if (mode > 2) {
LOG_WARNING(F("set wWMode: Invalid control mode: %d"), mode);
return;
}
if ((flags() & 0x0F) == EMS_DEVICE_FLAG_RC35 || (flags() & 0x0F) == EMS_DEVICE_FLAG_RC30_1) {
LOG_INFO(F("Setting wWMode to %d"), mode);
write_command(0x37, 2, mode);
}
}
// sets the thermostat ww working mode, where mode is a string
void Thermostat::set_ww_mode(const std::string & mode) {
if (strcasecmp("off",mode.c_str()) == 0) {
set_ww_mode(0);
} if (strcasecmp("on",mode.c_str()) == 0) {
set_ww_mode(1);
} else if (strcasecmp("auto",mode.c_str()) == 0) {
set_ww_mode(2);
}
}
// sets the thermostat working mode, where mode is a string
void Thermostat::set_mode(const std::string & mode, const uint8_t hc_num) {
if (mode_tostring(HeatingCircuit::Mode::OFF) == mode) {
@@ -1359,7 +1391,11 @@ void Thermostat::set_mode(const uint8_t mode, const uint8_t hc_num) {
}
break;
case EMSdevice::EMS_DEVICE_FLAG_JUNKERS:
offset = EMS_OFFSET_JunkersSetMessage_set_mode;
if ((flags() & EMS_DEVICE_FLAG_JUNKERS_2) == EMS_DEVICE_FLAG_JUNKERS_2) {
offset = EMS_OFFSET_JunkersSetMessage2_set_mode;
} else {
offset = EMS_OFFSET_JunkersSetMessage_set_mode;
}
validate_typeid = monitor_typeids[hc_p];
if (mode == HeatingCircuit::Mode::NOFROST) {
set_mode_value = 0x01;
@@ -1621,6 +1657,22 @@ void Thermostat::console_commands(Shell & shell, unsigned int context) {
};
});
EMSESPShell::commands->add_command(
ShellContext::THERMOSTAT,
CommandFlags::ADMIN,
flash_string_vector{F_(change), F_(mode)},
flash_string_vector{F_(mode_mandatory)},
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
set_ww_mode(arguments.front());
},
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) -> const std::vector<std::string> {
return std::vector<std::string>{read_flash_string(F("off")),
read_flash_string(F("on")),
read_flash_string(F("auto"))
};
});
EMSESPShell::commands->add_command(ShellContext::THERMOSTAT,
CommandFlags::USER,
flash_string_vector{F_(show)},

View File

@@ -130,6 +130,7 @@ class Thermostat : public EMSdevice {
uint8_t wwSystem_ = EMS_VALUE_UINT_NOTSET;
uint8_t wwExtra_ = EMS_VALUE_UINT_NOTSET;
uint8_t wwMode_ = EMS_VALUE_UINT_NOTSET;
std::vector<std::shared_ptr<HeatingCircuit>> heating_circuits_; // each thermostat can have multiple heating circuits
@@ -195,6 +196,7 @@ class Thermostat : public EMSdevice {
static constexpr uint8_t EMS_OFFSET_JunkersSetMessage_night_temp = 16; // EMS offset to set temperature on thermostat for night mode
static constexpr uint8_t EMS_OFFSET_JunkersSetMessage_no_frost_temp = 15; // EMS offset to set temperature on thermostat for no frost mode
static constexpr uint8_t EMS_OFFSET_JunkersSetMessage_set_mode = 14; // EMS offset to set mode on thermostat
static constexpr uint8_t EMS_OFFSET_JunkersSetMessage2_set_mode = 4; // EMS offset to set mode on thermostat
static constexpr uint8_t EMS_OFFSET_JunkersSetMessage2_no_frost_temp = 5;
static constexpr uint8_t EMS_OFFSET_JunkersSetMessage2_eco_temp = 6;
static constexpr uint8_t EMS_OFFSET_JunkersSetMessage3_heat = 7;
@@ -204,6 +206,7 @@ class Thermostat : public EMSdevice {
// Installation settings
static constexpr uint8_t EMS_TYPE_IBASettings = 0xA5; // installation settings
static constexpr uint8_t EMS_TYPE_wwSettings = 0x37; // ww settings
std::shared_ptr<Thermostat::HeatingCircuit> heating_circuit(std::shared_ptr<const Telegram> telegram);
std::shared_ptr<Thermostat::HeatingCircuit> heating_circuit(const uint8_t hc_num);
@@ -211,6 +214,7 @@ class Thermostat : public EMSdevice {
void process_RCOutdoorTemp(std::shared_ptr<const Telegram> telegram);
void process_IBASettings(std::shared_ptr<const Telegram> telegram);
void process_RCTime(std::shared_ptr<const Telegram> telegram);
void process_RC35wwSettings(std::shared_ptr<const Telegram> telegram);
void process_RC35Monitor(std::shared_ptr<const Telegram> telegram);
void process_RC35Set(std::shared_ptr<const Telegram> telegram);
@@ -246,6 +250,8 @@ class Thermostat : public EMSdevice {
void set_settings_building(const uint8_t bg);
void set_settings_language(const uint8_t lg);
void set_control(const uint8_t ctrl, const uint8_t hc_num);
void set_ww_mode(const uint8_t mode);
void set_ww_mode(const std::string & mode);
void set_mode(const uint8_t mode, const uint8_t hc_num);
void set_mode(const std::string & mode, const uint8_t hc_num);
void set_temperature(const float temperature, const std::string & mode, const uint8_t hc_num);