From 9ae8f4ef579e7c1117171e9469f09155dba4efd9 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 14 Sep 2020 08:51:09 +0200 Subject: [PATCH] add boiler heatingactivated, automaic select parameter telegrams for write --- src/devices/boiler.cpp | 103 +++++++++++++++++++++++++++++++++++++---- src/devices/boiler.h | 35 ++++++++------ src/emsdevice.cpp | 11 +++++ src/emsdevice.h | 1 + 4 files changed, 128 insertions(+), 22 deletions(-) diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index d092c1803..45b74154c 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -48,7 +48,9 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const register_telegram_type(0xE3, F("UBAMonitorSlowPlus"), false, [&](std::shared_ptr t) { process_UBAMonitorSlowPlus2(t); }); register_telegram_type(0xE4, F("UBAMonitorFastPlus"), false, [&](std::shared_ptr t) { process_UBAMonitorFastPlus(t); }); register_telegram_type(0xE5, F("UBAMonitorSlowPlus"), false, [&](std::shared_ptr t) { process_UBAMonitorSlowPlus(t); }); + register_telegram_type(0xE6, F("UBAParametersPlus"), true, [&](std::shared_ptr t) { process_UBAParametersPlus(t); }); register_telegram_type(0xE9, F("UBADHWStatus"), false, [&](std::shared_ptr t) { process_UBADHWStatus(t); }); + register_telegram_type(0xEA, F("UBAParameterWWPlus"), true, [&](std::shared_ptr t) { process_UBAParameterWWPlus(t); }); // MQTT commands for boiler_cmd topic register_mqtt_cmd(F("comfort"), [&](const char * value, const int8_t id) { set_warmwater_mode(value, id); }); @@ -58,6 +60,8 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const register_mqtt_cmd(F("wwcirculation"), [&](const char * value, const int8_t id) { set_warmwater_circulation(value, id); }); register_mqtt_cmd(F("flowtemp"), [&](const char * value, const int8_t id) { set_flow_temp(value, id); }); register_mqtt_cmd(F("wwtemp"), [&](const char * value, const int8_t id) { set_warmwater_temp(value, id); }); + register_mqtt_cmd(F("heatingactivated"), [&](const char * value, const int8_t id) { set_heating_activated(value, id); }); + register_mqtt_cmd(F("heatingtemp"), [&](const char * value, const int8_t id) { set_heating_temp(value, id); }); register_mqtt_cmd(F("burnmaxpower"), [&](const char * value, const int8_t id) { set_max_power(value, id); }); register_mqtt_cmd(F("burnminpower"), [&](const char * value, const int8_t id) { set_min_power(value, id); }); register_mqtt_cmd(F("boilhyston"), [&](const char * value, const int8_t id) { set_hyst_on(value, id); }); @@ -266,6 +270,9 @@ void Boiler::publish_values() { if (Helpers::hasValue(wWHeat_, EMS_VALUE_BOOL)) { doc["wWHeat"] = Helpers::render_value(s, wWHeat_, EMS_VALUE_BOOL); } + if (Helpers::hasValue(heating_activated_, EMS_VALUE_BOOL)) { + doc["heatingActivated"] = Helpers::render_value(s, heating_activated_, EMS_VALUE_BOOL); + } if (Helpers::hasValue(heating_temp_)) { doc["heatingTemp"] = heating_temp_; } @@ -415,6 +422,7 @@ void Boiler::show_values(uuid::console::Shell & shell) { } // UBAParameters + print_value(shell, 2, F("Heating activated"), heating_activated_, nullptr, EMS_VALUE_BOOL); print_value(shell, 2, F("Heating temperature setting on the boiler"), heating_temp_, F_(degrees)); 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)); @@ -542,6 +550,7 @@ void Boiler::process_UBATotalUptime(std::shared_ptr telegram) { * UBAParameters - type 0x16 */ void Boiler::process_UBAParameters(std::shared_ptr telegram) { + changed_ |= telegram->read_value(heating_activated_, 0); changed_ |= telegram->read_value(heating_temp_, 1); changed_ |= telegram->read_value(burnPowermax_, 2); changed_ |= telegram->read_value(burnPowermin_, 3); @@ -636,6 +645,28 @@ void Boiler::process_UBAMonitorSlowPlus(std::shared_ptr telegram changed_ |= telegram->read_value(pumpMod_, 25); } +/* + * UBAParametersPlus - type 0xe6 + */ +void Boiler::process_UBAParametersPlus(std::shared_ptr telegram) { + changed_ |= telegram->read_value(heating_activated_, 0); + changed_ |= telegram->read_value(heating_temp_, 1); + changed_ |= telegram->read_value(burnPowermax_, 6); + changed_ |= telegram->read_value(burnPowermin_, 7); + changed_ |= telegram->read_value(boilTemp_off_, 8); + changed_ |= telegram->read_value(boilTemp_on_, 9); + changed_ |= telegram->read_value(burnPeriod_, 10); +} + +// 0xEA +void Boiler::process_UBAParameterWWPlus(std::shared_ptr telegram) { + changed_ |= telegram->read_value(wWActivated_, 5); // 0x01 means on + changed_ |= telegram->read_value(wWCircPump_, 10); // 0x01 means yes + changed_ |= telegram->read_value(wWCircPumpMode_, 11); // 1=1x3min... 6=6x3min, 7=continuous + // changed_ |= telegram->read_value(wWDisinfectTemp_, 12); // also in E9 + // changed_ |= telegram->read_value(wWSelTemp_, 6); +} + // 0xE9 - DHW Status // e.g. 08 00 E9 00 37 01 F6 01 ED 00 00 00 00 41 3C 00 00 00 00 00 00 00 00 00 00 00 00 37 00 00 00 (CRC=77) #data=27 void Boiler::process_UBADHWStatus(std::shared_ptr telegram) { @@ -724,8 +755,12 @@ void Boiler::set_warmwater_temp(const char * value, const int8_t id) { } LOG_INFO(F("Setting boiler warm water temperature to %d C"), v); - write_command(EMS_TYPE_UBAParameterWW, 2, v, EMS_TYPE_UBAParameterWW); - write_command(EMS_TYPE_UBAFlags, 3, v, EMS_TYPE_UBAParameterWW); // for i9000, see #397 + if (get_toggle_fetch(EMS_TYPE_UBAParametersPlus)) { + write_command(EMS_TYPE_UBAParameterWWPlus, 6, v, EMS_TYPE_UBAParameterWWPlus); + } else { + write_command(EMS_TYPE_UBAParameterWW, 2, v, EMS_TYPE_UBAParameterWW); + write_command(EMS_TYPE_UBAFlags, 3, v, EMS_TYPE_UBAParameterWW); // for i9000, see #397 + } } // flow temp @@ -739,6 +774,34 @@ void Boiler::set_flow_temp(const char * value, const int8_t id) { write_command(EMS_TYPE_UBASetPoints, 0, v, EMS_TYPE_UBASetPoints); } +// set min boiler output +void Boiler::set_heating_activated(const char * value, const int8_t id) { + bool v = false; + if (!Helpers::value2bool (value, v)) { + return; + } + LOG_INFO(F("Setting boiler heating "), v ? "on" : "off"); + if (get_toggle_fetch(EMS_TYPE_UBAParametersPlus)) { + write_command(EMS_TYPE_UBAParametersPlus, 0, v ? 0x01 : 0, EMS_TYPE_UBAParametersPlus); + } else { + write_command(EMS_TYPE_UBAParameters, 0, v ? 0xFF : 0, EMS_TYPE_UBAParameters); + } +} + +// set heating maximum temperature +void Boiler::set_heating_temp(const char * value, const int8_t id) { + int v = 0; + if (!Helpers::value2number(value, v)) { + return; + } + LOG_INFO(F("Setting boiler heating temperature to "), v); + if (get_toggle_fetch(EMS_TYPE_UBAParametersPlus)) { + write_command(EMS_TYPE_UBAParametersPlus, 1, v, EMS_TYPE_UBAParametersPlus); + } else { + write_command(EMS_TYPE_UBAParameters, 1, v, EMS_TYPE_UBAParameters); + } +} + // set min boiler output void Boiler::set_min_power(const char * value, const int8_t id) { int v = 0; @@ -746,7 +809,11 @@ void Boiler::set_min_power(const char * value, const int8_t id) { return; } LOG_INFO(F("Setting boiler min power to "), v); - write_command(EMS_TYPE_UBAParameters, 3, v, EMS_TYPE_UBAParameters); + if (get_toggle_fetch(EMS_TYPE_UBAParametersPlus)) { + write_command(EMS_TYPE_UBAParametersPlus, 7, v, EMS_TYPE_UBAParametersPlus); + } else { + write_command(EMS_TYPE_UBAParameters, 3, v, EMS_TYPE_UBAParameters); + } } // set max temp @@ -757,7 +824,11 @@ void Boiler::set_max_power(const char * value, const int8_t id) { } LOG_INFO(F("Setting boiler max power to %d C"), v); - write_command(EMS_TYPE_UBAParameters, 2, v, EMS_TYPE_UBAParameters); + if (get_toggle_fetch(EMS_TYPE_UBAParametersPlus)) { + write_command(EMS_TYPE_UBAParametersPlus, 6, v, EMS_TYPE_UBAParametersPlus); + } else { + write_command(EMS_TYPE_UBAParameters, 2, v, EMS_TYPE_UBAParameters); + } } // set boiler on hysteresis @@ -768,7 +839,11 @@ void Boiler::set_hyst_on(const char * value, const int8_t id) { } LOG_INFO(F("Setting boiler hysteresis on to %d C"), v); - write_command(EMS_TYPE_UBAParameters, 5, v, EMS_TYPE_UBAParameters); + if (get_toggle_fetch(EMS_TYPE_UBAParametersPlus)) { + write_command(EMS_TYPE_UBAParametersPlus, 9, v, EMS_TYPE_UBAParametersPlus); + } else { + write_command(EMS_TYPE_UBAParameters, 5, v, EMS_TYPE_UBAParameters); + } } // set boiler off hysteresis @@ -779,7 +854,11 @@ void Boiler::set_hyst_off(const char * value, const int8_t id) { } LOG_INFO(F("Setting boiler hysteresis off to %d C"), v); - write_command(EMS_TYPE_UBAParameters, 4, v, EMS_TYPE_UBAParameters); + if (get_toggle_fetch(EMS_TYPE_UBAParametersPlus)) { + write_command(EMS_TYPE_UBAParametersPlus, 8, v, EMS_TYPE_UBAParametersPlus); + } else { + write_command(EMS_TYPE_UBAParameters, 4, v, EMS_TYPE_UBAParameters); + } } // set min burner period @@ -790,7 +869,11 @@ void Boiler::set_burn_period(const char * value, const int8_t id) { } LOG_INFO(F("Setting burner min. period to %d min"), v); - write_command(EMS_TYPE_UBAParameters, 6, v, EMS_TYPE_UBAParameters); + if (get_toggle_fetch(EMS_TYPE_UBAParametersPlus)) { + write_command(EMS_TYPE_UBAParametersPlus, 10, v, EMS_TYPE_UBAParametersPlus); + } else { + write_command(EMS_TYPE_UBAParameters, 6, v, EMS_TYPE_UBAParameters); + } } // set pump delay @@ -842,7 +925,11 @@ void Boiler::set_warmwater_activated(const char * value, const int8_t id) { } else { n = (v ? 0xFF : 0x00); // 0xFF is on, 0x00 is off } - write_command(EMS_TYPE_UBAParameterWW, 1, n, EMS_TYPE_UBAParameterWW); + if (get_toggle_fetch(EMS_TYPE_UBAParameterWWPlus)) { + write_command(EMS_TYPE_UBAParameterWWPlus, 1, v ? 1 : 0, EMS_TYPE_UBAParameterWWPlus); + } else { + write_command(EMS_TYPE_UBAParameterWW, 1, n, EMS_TYPE_UBAParameterWW); + } } // Activate / De-activate the Warm Tap Water diff --git a/src/devices/boiler.h b/src/devices/boiler.h index 7ae907573..864fe65f6 100644 --- a/src/devices/boiler.h +++ b/src/devices/boiler.h @@ -55,11 +55,13 @@ class Boiler : public EMSdevice { uint8_t mqtt_format_; // single, nested or ha bool changed_ = false; - static constexpr uint8_t EMS_TYPE_UBAParameterWW = 0x33; - 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_TYPE_UBAParameterWW = 0x33; + 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_TYPE_UBAParametersPlus = 0xE6; + static constexpr uint8_t EMS_TYPE_UBAParameterWWPlus = 0xEA; static constexpr uint8_t EMS_BOILER_SELFLOWTEMP_HEATING = 20; // was originally 70, changed to 30 for issue #193, then to 20 with issue #344 @@ -122,15 +124,16 @@ class Boiler : public EMSdevice { uint32_t UBAuptime_ = EMS_VALUE_ULONG_NOTSET; // Total UBA working hours // UBAParameters - uint8_t heating_temp_ = EMS_VALUE_UINT_NOTSET; // Heating temperature setting on the boiler - 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 - uint8_t burnPowermin_ = EMS_VALUE_UINT_NOTSET; - uint8_t burnPowermax_ = EMS_VALUE_UINT_NOTSET; - int8_t boilTemp_off_ = EMS_VALUE_INT_NOTSET; - int8_t boilTemp_on_ = EMS_VALUE_INT_NOTSET; - uint8_t burnPeriod_ = EMS_VALUE_UINT_NOTSET; - uint8_t pumpDelay_ = EMS_VALUE_UINT_NOTSET; + uint8_t heating_activated_ = EMS_VALUE_BOOL_NOTSET; // Heating activated on the boiler + uint8_t heating_temp_ = EMS_VALUE_UINT_NOTSET; // Heating temperature setting on the boiler + 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 + uint8_t burnPowermin_ = EMS_VALUE_UINT_NOTSET; + uint8_t burnPowermax_ = EMS_VALUE_UINT_NOTSET; + int8_t boilTemp_off_ = EMS_VALUE_INT_NOTSET; + int8_t boilTemp_on_ = EMS_VALUE_INT_NOTSET; + uint8_t burnPeriod_ = EMS_VALUE_UINT_NOTSET; + uint8_t pumpDelay_ = EMS_VALUE_UINT_NOTSET; // UBASetPoint uint8_t setFlowTemp_ = EMS_VALUE_UINT_NOTSET; // boiler setpoint temp @@ -151,6 +154,8 @@ class Boiler : public EMSdevice { void process_UBAMonitorSlow(std::shared_ptr telegram); void process_UBAMonitorSlowPlus(std::shared_ptr telegram); void process_UBAMonitorSlowPlus2(std::shared_ptr telegram); + void process_UBAParametersPlus(std::shared_ptr telegram); + void process_UBAParameterWWPlus(std::shared_ptr telegram); void process_UBAOutdoorTemp(std::shared_ptr telegram); void process_UBASetPoints(std::shared_ptr telegram); void process_UBAFlags(std::shared_ptr telegram); @@ -168,6 +173,8 @@ class Boiler : public EMSdevice { void set_warmwater_circulation(const char * value, const int8_t id); void set_warmwater_temp(const char * value, const int8_t id); void set_flow_temp(const char * value, const int8_t id); + void set_heating_activated(const char * value, const int8_t id); + void set_heating_temp(const char * value, const int8_t id); void set_min_power(const char * value, const int8_t id); void set_max_power(const char * value, const int8_t id); void set_hyst_on(const char * value, const int8_t id); diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 848041542..fbdced66c 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -222,6 +222,17 @@ void EMSdevice::toggle_fetch(uint16_t telegram_id, bool toggle) { } } +// get status of automatic fetch for a telegram id +bool EMSdevice::get_toggle_fetch(uint16_t telegram_id) { + for (auto & tf : telegram_functions_) { + if (tf.telegram_type_id_ == telegram_id) { + return tf.fetch_ ; + } + } + return false; +} + + // list all the telegram type IDs for this device void EMSdevice::show_telegram_handlers(uuid::console::Shell & shell) { if (telegram_functions_.size() == 0) { diff --git a/src/emsdevice.h b/src/emsdevice.h index b9160a888..fdd697288 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -146,6 +146,7 @@ class EMSdevice { void fetch_values(); void toggle_fetch(uint16_t telegram_id, bool toggle); + bool get_toggle_fetch(uint16_t telegram_id); void reserve_mem(size_t n) { telegram_functions_.reserve(n);