From b4ceef82d5faead68903dcc17e54d6992f732902 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Tue, 27 Oct 2020 19:38:23 +0100 Subject: [PATCH] add thermostat flowtempoffset --- src/devices/thermostat.cpp | 41 +++++++++++++++++++++++++++----------- src/devices/thermostat.h | 5 ++++- src/locale_EN.h | 1 + 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 6627d64ab..4029576f4 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -220,6 +220,7 @@ void Thermostat::device_info_web(JsonArray & root) { print_value_json(root, F("offsettemp"), FPSTR(prefix_str), F_(offsettemp), F_(degrees), json); print_value_json(root, F("designtemp"), FPSTR(prefix_str), F_(designtemp), F_(degrees), json); print_value_json(root, F("roominfluence"), FPSTR(prefix_str), F_(roominfluence), F_(degrees), json); + print_value_json(root, F("flowtempoffset"), FPSTR(prefix_str), F_(flowtempoffset), F_(degrees), json); print_value_json(root, F("summertemp"), FPSTR(prefix_str), F_(summertemp), F_(degrees), json); print_value_json(root, F("summermode"), FPSTR(prefix_str), F_(summermode), F_(degrees), json); print_value_json(root, F("mode"), FPSTR(prefix_str), F_(mode), nullptr, json); @@ -301,6 +302,7 @@ void Thermostat::show_values(uuid::console::Shell & shell) { print_value_json(shell, F("offsettemp"), F_(2spaces), F_(offsettemp), F_(degrees), json); print_value_json(shell, F("designtemp"), F_(2spaces), F_(designtemp), F_(degrees), json); print_value_json(shell, F("roominfluence"), F_(2spaces), F_(roominfluence), F_(degrees), json); + print_value_json(shell, F("flowtempoffset"), F_(2spaces), F_(flowtempoffset), F_(degrees), json); print_value_json(shell, F("summertemp"), F_(2spaces), F_(summertemp), F_(degrees), json); print_value_json(shell, F("summermode"), F_(2spaces), F_(summermode), F_(degrees), json); print_value_json(shell, F("mode"), F_(2spaces), F_(mode), nullptr, json); @@ -475,9 +477,7 @@ bool Thermostat::export_values_hc(uint8_t mqtt_format, JsonObject & rootThermost dataThermostat = rootThermostat; } else { char hc_name[10]; // hc{1-4} - strlcpy(hc_name, "hc", 10); - char s[3]; - strlcat(hc_name, Helpers::itoa(s, hc->hc_num()), 10); + snprintf_P(hc_name, 10, PSTR("hc%d"), hc->hc_num()); dataThermostat = rootThermostat.createNestedObject(hc_name); } @@ -572,6 +572,11 @@ bool Thermostat::export_values_hc(uint8_t mqtt_format, JsonObject & rootThermost dataThermostat["roominfluence"] = hc->roominfluence; } + // Flow temperature offset + if (Helpers::hasValue(hc->flowtempoffset)) { + dataThermostat["flowtempoffset"] = hc->flowtempoffset; + } + // Summer temperature if (Helpers::hasValue(hc->summertemp)) { dataThermostat["summertemp"] = hc->summertemp; @@ -1243,6 +1248,8 @@ void Thermostat::process_RC300WWtemp(std::shared_ptr telegram) { // type 02F5 void Thermostat::process_RC300WWmode(std::shared_ptr telegram) { + // circulation pump see: https://github.com/Th3M3/buderus_ems-wiki/blob/master/Einstellungen%20der%20Bedieneinheit%20RC310.md + // changed_ |= telegram->read_value(wwCircMode_, 1); // 0=off, FF=on changed_ |= telegram->read_value(wwMode_, 2); // 0=off, 1=low, 2=high, 3=auto, 4=own prog } @@ -1304,21 +1311,22 @@ void Thermostat::process_RC35Set(std::shared_ptr telegram) { std::shared_ptr hc = heating_circuit(telegram); - changed_ |= telegram->read_value(hc->mode, 7); // night, day, auto - changed_ |= telegram->read_value(hc->daytemp, 2); // is * 2 - changed_ |= telegram->read_value(hc->nighttemp, 1); // is * 2 - changed_ |= telegram->read_value(hc->holidaytemp, 3); // is * 2 - changed_ |= telegram->read_value(hc->heatingtype, 0); // 0- off, 1-radiator, 2-convector, 3-floor + changed_ |= telegram->read_value(hc->heatingtype, 0); // 0- off, 1-radiator, 2-convector, 3-floor + changed_ |= telegram->read_value(hc->nighttemp, 1); // is * 2 + changed_ |= telegram->read_value(hc->daytemp, 2); // is * 2 + changed_ |= telegram->read_value(hc->holidaytemp, 3); // is * 2 + changed_ |= telegram->read_value(hc->roominfluence, 4); // is * 1 + changed_ |= telegram->read_value(hc->offsettemp, 6); // is * 2 + changed_ |= telegram->read_value(hc->mode, 7); // night, day, auto - changed_ |= telegram->read_value(hc->summertemp, 22); // is * 1 - changed_ |= telegram->read_value(hc->nofrosttemp, 23); // is * 1 + changed_ |= telegram->read_value(hc->summertemp, 22); // is * 1 + changed_ |= telegram->read_value(hc->nofrosttemp, 23); // is * 1 + changed_ |= telegram->read_value(hc->flowtempoffset, 24); // is * 1, only in mixed circuits if (hc->heatingtype == 3) { changed_ |= telegram->read_value(hc->designtemp, 36); // is * 1 } else { changed_ |= telegram->read_value(hc->designtemp, 17); // is * 1 } - changed_ |= telegram->read_value(hc->offsettemp, 6); // is * 2 - changed_ |= telegram->read_value(hc->roominfluence, 4); // is * 1 } // process_RCTime - type 0x06 - date and time from a thermostat - 14 bytes long @@ -1986,6 +1994,10 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co case HeatingCircuit::Mode::OFFSET: // change the offset temp offset = EMS_OFFSET_RC35Set_temp_offset; break; + case HeatingCircuit::Mode::FLOWOFFSET: // change the offset of flowtemp + offset = EMS_OFFSET_RC35Set_temp_flowoffset; + factor = 1; + break; case HeatingCircuit::Mode::DESIGN: if (hc->heatingtype == 3) { offset = EMS_OFFSET_RC35Set_temp_design_floor; @@ -2157,6 +2169,10 @@ bool Thermostat::set_manualtemp(const char * value, const int8_t id) { return set_temperature_value(value, id, HeatingCircuit::Mode::MANUAL); } +bool Thermostat::set_flowtempoffset(const char * value, const int8_t id) { + return set_temperature_value(value, id, HeatingCircuit::Mode::FLOWOFFSET); +} + // API commands for MQTT and Console void Thermostat::add_commands() { // if this thermostat doesn't support write, don't add the commands @@ -2209,6 +2225,7 @@ void Thermostat::add_commands() { register_mqtt_cmd(F("wwmode"), [&](const char * value, const int8_t id) { return set_wwmode(value, id); }); register_mqtt_cmd(F("wwcircmode"), [&](const char * value, const int8_t id) { return set_wwcircmode(value, id); }); register_mqtt_cmd(F("roominfluence"), [&](const char * value, const int8_t id) { return set_roominfluence(value, id); }); + register_mqtt_cmd(F("flowtempoffset"), [&](const char * value, const int8_t id) { return set_flowtempoffset(value, id); }); break; case EMS_DEVICE_FLAG_JUNKERS: register_mqtt_cmd(F("nofrosttemp"), [&](const char * value, const int8_t id) { return set_nofrosttemp(value, id); }); diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index d32d1fa5b..ff3d7b311 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -64,6 +64,7 @@ class Thermostat : public EMSdevice { uint8_t manualtemp = EMS_VALUE_UINT_NOTSET; uint8_t summer_setmode = EMS_VALUE_UINT_NOTSET; uint8_t roominfluence = EMS_VALUE_UINT_NOTSET; + uint8_t flowtempoffset = EMS_VALUE_UINT_NOTSET; uint8_t hc_num() const { return hc_num_; @@ -85,7 +86,7 @@ class Thermostat : public EMSdevice { uint8_t get_mode(uint8_t flags) const; uint8_t get_mode_type(uint8_t flags) const; - enum Mode : uint8_t { UNKNOWN, OFF, MANUAL, AUTO, DAY, NIGHT, HEAT, NOFROST, ECO, HOLIDAY, COMFORT, OFFSET, DESIGN, SUMMER }; + enum Mode : uint8_t { UNKNOWN, OFF, MANUAL, AUTO, DAY, NIGHT, HEAT, NOFROST, ECO, HOLIDAY, COMFORT, OFFSET, DESIGN, SUMMER, FLOWOFFSET }; // for sorting based on hc number friend inline bool operator<(const std::shared_ptr & lhs, const std::shared_ptr & rhs) { @@ -195,6 +196,7 @@ class Thermostat : public EMSdevice { static constexpr uint8_t EMS_OFFSET_RC35Set_targetflowtemp = 14; // target flow temperature static constexpr uint8_t EMS_OFFSET_RC35Set_seltemp = 37; // selected temp static constexpr uint8_t EMS_OFFSET_RC35Set_temp_offset = 6; + static constexpr uint8_t EMS_OFFSET_RC35Set_temp_flowoffset = 24; static constexpr uint8_t EMS_OFFSET_RC35Set_temp_design = 17; static constexpr uint8_t EMS_OFFSET_RC35Set_temp_design_floor = 36; static constexpr uint8_t EMS_OFFSET_RC35Set_temp_summer = 22; @@ -299,6 +301,7 @@ class Thermostat : public EMSdevice { bool set_manualtemp(const char * value, const int8_t id); bool set_remotetemp(const char * value, const int8_t id); bool set_roominfluence(const char * value, const int8_t id); + bool set_flowtempoffset(const char * value, const int8_t id); // set functions - these don't use the id/hc, the parameters are ignored bool set_wwmode(const char * value, const int8_t id); diff --git a/src/locale_EN.h b/src/locale_EN.h index 5c648e561..9d59997d0 100644 --- a/src/locale_EN.h +++ b/src/locale_EN.h @@ -262,6 +262,7 @@ MAKE_PSTR(designtemp, "Design temperature") MAKE_PSTR(summertemp, "Summer temperature") MAKE_PSTR(summermode, "Summer mode") MAKE_PSTR(roominfluence, "Room influence") +MAKE_PSTR(flowtempoffset, "Flow temperature offset") MAKE_PSTR(mode, "Mode") MAKE_PSTR(modetype, "Mode type")