From 79d0db0bbd3844ef9c9a2511a872e6bad64790af Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 4 Mar 2021 16:15:38 +0100 Subject: [PATCH] Namings like v2.2.1 --- src/devices/boiler.cpp | 55 +++++++++++++------------- src/devices/boiler.h | 6 +-- src/devices/mixer.cpp | 20 +++++----- src/devices/mixer.h | 2 +- src/devices/solar.cpp | 28 ++++++------- src/devices/solar.h | 10 ++--- src/devices/switch.cpp | 8 ++-- src/devices/switch.h | 2 +- src/devices/thermostat.cpp | 80 ++++++++------------------------------ src/devices/thermostat.h | 5 +-- src/emsdevice.cpp | 8 +++- src/emsdevice.h | 8 ++-- src/shower.cpp | 8 +--- 13 files changed, 97 insertions(+), 143 deletions(-) diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index a449076cf..352a65552 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -60,6 +60,8 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const device_id); // read last errorcode on start (only published on errors) EMSESP::send_read_request(0x15, device_id); // read maintenace data on start (only published on change) + EMSESP::send_read_request(0x1C, + device_id); // read maintenace status on start (only published on change) // MQTT commands for boiler topic register_mqtt_cmd(F("comfort"), [&](const char * value, const int8_t id) { return set_warmwater_mode(value, id); }); @@ -70,7 +72,7 @@ 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) { return set_warmwater_circulation(value, id); }); register_mqtt_cmd(F("wwcircmode"), [&](const char * value, const int8_t id) { return set_warmwater_circulation_mode(value, id); }); register_mqtt_cmd(F("flowtemp"), [&](const char * value, const int8_t id) { return set_flow_temp(value, id); }); - register_mqtt_cmd(F("wwtemp"), [&](const char * value, const int8_t id) { return set_warmwater_temp(value, id); }); + register_mqtt_cmd(F("wwsettemp"), [&](const char * value, const int8_t id) { return set_warmwater_temp(value, id); }); register_mqtt_cmd(F("heatingactivated"), [&](const char * value, const int8_t id) { return set_heating_activated(value, id); }); register_mqtt_cmd(F("heatingtemp"), [&](const char * value, const int8_t id) { return set_heating_temp(value, id); }); register_mqtt_cmd(F("burnmaxpower"), [&](const char * value, const int8_t id) { return set_max_power(value, id); }); @@ -96,8 +98,8 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const register_device_value(TAG_BOILER_DATA, &selFlowTemp_, DeviceValueType::UINT, nullptr, F("selFlowTemp"), F("Selected flow temperature"), DeviceValueUOM::DEGREES); register_device_value(TAG_BOILER_DATA, &selBurnPow_, DeviceValueType::UINT, nullptr, F("selBurnPow"), F("Burner selected max power"), DeviceValueUOM::PERCENT); - register_device_value(TAG_BOILER_DATA, &pumpMod_, DeviceValueType::UINT, nullptr, F("pumpMod"), F("Pump modulation"), DeviceValueUOM::PERCENT); - register_device_value(TAG_BOILER_DATA, &pumpMod2_, DeviceValueType::UINT, nullptr, F("pumpMod2"), F("Heat pump modulation"), DeviceValueUOM::PERCENT); + register_device_value(TAG_BOILER_DATA, &heatingPumpMod_, DeviceValueType::UINT, nullptr, F("heatingPumpMod"), F("Heating pump modulation"), DeviceValueUOM::PERCENT); + register_device_value(TAG_BOILER_DATA, &heatingPump2Mod_, DeviceValueType::UINT, nullptr, F("heatingPump2Mod"), F("Heating pump 2 modulation"), DeviceValueUOM::PERCENT); register_device_value(TAG_BOILER_DATA, &outdoorTemp_, DeviceValueType::SHORT, FL_(div10), F("outdoorTemp"), F("Outside temperature"), DeviceValueUOM::DEGREES); register_device_value(TAG_BOILER_DATA, &curFlowTemp_, DeviceValueType::USHORT, FL_(div10), F("curFlowTemp"), F("Current flow temperature"), DeviceValueUOM::DEGREES); @@ -109,7 +111,7 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const register_device_value(TAG_BOILER_DATA, &burnGas_, DeviceValueType::BOOL, nullptr, F("burnGas"), F("Gas")); register_device_value(TAG_BOILER_DATA, &flameCurr_, DeviceValueType::USHORT, FL_(div10), F("flameCurr"), F("Flame current"), DeviceValueUOM::UA); - register_device_value(TAG_BOILER_DATA, &heatPump_, DeviceValueType::BOOL, nullptr, F("heatPump"), F("Heat pump")); + register_device_value(TAG_BOILER_DATA, &heatingPump_, DeviceValueType::BOOL, nullptr, F("heatingPump"), F("Heating pump"), DeviceValueUOM::PUMP); register_device_value(TAG_BOILER_DATA, &fanWork_, DeviceValueType::BOOL, nullptr, F("fanWork"), F("Fan")); register_device_value(TAG_BOILER_DATA, &ignWork_, DeviceValueType::BOOL, nullptr, F("ignWork"), F("Ignition")); register_device_value(TAG_BOILER_DATA, &heatingActivated_, DeviceValueType::BOOL, nullptr, F("heatingActivated"), F("Heating activated")); @@ -289,7 +291,7 @@ void Boiler::process_UBAMonitorFast(std::shared_ptr telegram) { has_update(telegram->read_bitvalue(burnGas_, 7, 0)); has_update(telegram->read_bitvalue(fanWork_, 7, 2)); has_update(telegram->read_bitvalue(ignWork_, 7, 3)); - has_update(telegram->read_bitvalue(heatPump_, 7, 5)); + has_update(telegram->read_bitvalue(heatingPump_, 7, 5)); has_update(telegram->read_bitvalue(wWHeat_, 7, 6)); has_update(telegram->read_bitvalue(wWCirc_, 7, 7)); @@ -376,7 +378,7 @@ void Boiler::process_UBAMonitorWW(std::shared_ptr telegram) { void Boiler::process_UBAMonitorFastPlus(std::shared_ptr telegram) { has_update(telegram->read_value(selFlowTemp_, 6)); has_update(telegram->read_bitvalue(burnGas_, 11, 0)); - // has_update(telegram->read_bitvalue(heatPump_, 11, 1)); // heating active? see SlowPlus + // has_update(telegram->read_bitvalue(heatingPump_, 11, 1)); // heating active? see SlowPlus has_update(telegram->read_bitvalue(wWHeat_, 11, 2)); has_update(telegram->read_value(curBurnPow_, 10)); has_update(telegram->read_value(selBurnPow_, 9)); @@ -424,7 +426,7 @@ void Boiler::process_UBAMonitorSlow(std::shared_ptr telegram) { has_update(telegram->read_value(exhaustTemp_, 4)); has_update(telegram->read_value(switchTemp_, 25)); // only if there is a mixer module present - has_update(telegram->read_value(pumpMod_, 9)); + has_update(telegram->read_value(heatingPumpMod_, 9)); has_update(telegram->read_value(burnStarts_, 10, 3)); // force to 3 bytes has_update(telegram->read_value(burnWorkMin_, 13, 3)); // force to 3 bytes has_update(telegram->read_value(heatWorkMin_, 19, 3)); // force to 3 bytes @@ -435,7 +437,7 @@ void Boiler::process_UBAMonitorSlow(std::shared_ptr telegram) { * 88 00 E3 00 04 00 00 00 00 01 00 00 00 00 00 02 22 2B 64 46 01 00 00 61 */ void Boiler::process_UBAMonitorSlowPlus2(std::shared_ptr telegram) { - has_update(telegram->read_value(pumpMod2_, 13)); // Heat Pump Modulation + has_update(telegram->read_value(heatingPump2Mod_, 13)); // Heat Pump Modulation } /* @@ -446,13 +448,13 @@ void Boiler::process_UBAMonitorSlowPlus2(std::shared_ptr telegra void Boiler::process_UBAMonitorSlowPlus(std::shared_ptr telegram) { has_update(telegram->read_bitvalue(fanWork_, 2, 2)); has_update(telegram->read_bitvalue(ignWork_, 2, 3)); - has_update(telegram->read_bitvalue(heatPump_, 2, 5)); + has_update(telegram->read_bitvalue(heatingPump_, 2, 5)); has_update(telegram->read_bitvalue(wWCirc_, 2, 7)); has_update(telegram->read_value(exhaustTemp_, 6)); has_update(telegram->read_value(burnStarts_, 10, 3)); // force to 3 bytes has_update(telegram->read_value(burnWorkMin_, 13, 3)); // force to 3 bytes has_update(telegram->read_value(heatWorkMin_, 19, 3)); // force to 3 bytes - has_update(telegram->read_value(pumpMod_, 25)); + has_update(telegram->read_value(heatingPumpMod_, 25)); // temperature measurements at 4, see #620 } @@ -474,10 +476,9 @@ void Boiler::process_UBAParametersPlus(std::shared_ptr telegram) // 0xEA void Boiler::process_UBAParameterWWPlus(std::shared_ptr telegram) { - has_update(telegram->read_value(wWActivated_, 5)); // 0x01 means on - has_update(telegram->read_value(wWCircPump_, 10)); // 0x01 means yes - has_update(telegram->read_value(wWCircPumpMode_, - 11)); // 1=1x3min... 6=6x3min, 7=continuous + has_update(telegram->read_value(wWActivated_, 5)); // 0x01 means on + has_update(telegram->read_value(wWCircPump_, 10)); // 0x01 means yes + has_update(telegram->read_value(wWCircPumpMode_, 11)); // 1=1x3min... 6=6x3min, 7=continuous // has_update(telegram->read_value(wWDisinfectTemp_, 12)); // settings, status in E9 // has_update(telegram->read_value(wWSelTemp_, 6)); // settings, status in E9 } @@ -631,18 +632,18 @@ void Boiler::process_UBAMaintenanceData(std::shared_ptr telegram has_update(telegram->read_value(maintenanceType_, 0)); - if (maintenanceType_ == 1) { - // time only, single byte * 100 - telegram->read_value(maintenanceTime_, 1, 1); - maintenanceTime_ = maintenanceTime_ * 100; - } else if (maintenanceType_ == 2) { - // date only - uint8_t day = telegram->message_data[2]; - uint8_t month = telegram->message_data[3]; - uint8_t year = telegram->message_data[4]; - if (day > 0 && month > 0) { - snprintf_P(maintenanceDate_, sizeof(maintenanceDate_), PSTR("%02d.%02d.%04d"), day, month, year + 2000); - } + uint8_t time = (maintenanceTime_ == EMS_VALUE_USHORT_NOTSET) ? EMS_VALUE_UINT_NOTSET : maintenanceTime_ / 100; + has_update(telegram->read_value(time, 1)); + maintenanceTime_ = (time == EMS_VALUE_UINT_NOTSET) ? EMS_VALUE_USHORT_NOTSET : time * 100; + // telegram->read_value(maintenanceTime_, 1, 1); + // maintenanceTime_ = maintenanceTime * 100; + + // date only + uint8_t day = telegram->message_data[2]; + uint8_t month = telegram->message_data[3]; + uint8_t year = telegram->message_data[4]; + if (day > 0 && month > 0) { + snprintf_P(maintenanceDate_, sizeof(maintenanceDate_), PSTR("%02d.%02d.%04d"), day, month, year + 2000); } } @@ -658,9 +659,9 @@ bool Boiler::set_warmwater_temp(const char * value, const int8_t id) { if (get_toggle_fetch(EMS_TYPE_UBAParametersPlus)) { write_command(EMS_TYPE_UBAParameterWWPlus, 6, v, EMS_TYPE_UBAParameterWWPlus); } else { + write_command(EMS_TYPE_UBAFlags, 3, v, 0x34); // for i9000, see #397 write_command(EMS_TYPE_UBAParameterWW, 2, v, EMS_TYPE_UBAParameterWW); // read seltemp back - write_command(EMS_TYPE_UBAFlags, 3, v, 0x34); // for i9000, see #397, read setTemp } return true; diff --git a/src/devices/boiler.h b/src/devices/boiler.h index 240816fdd..f9f748477 100644 --- a/src/devices/boiler.h +++ b/src/devices/boiler.h @@ -85,8 +85,8 @@ class Boiler : public EMSdevice { uint8_t tapwaterActive_; // Hot tap water is on/off uint8_t selFlowTemp_; // Selected flow temperature uint8_t selBurnPow_; // Burner max power % - uint8_t pumpMod2_; // heatpump modulation from 0xE3 (heatpumps) - uint8_t pumpMod_; // Pump modulation % + uint8_t heatingPump2Mod_; // heatpump modulation from 0xE3 (heatpumps) + uint8_t heatingPumpMod_; // Pump modulation % int16_t outdoorTemp_; // Outside temperature uint16_t curFlowTemp_; // Current flow temperature uint16_t retTemp_; // Return temperature @@ -96,7 +96,7 @@ class Boiler : public EMSdevice { uint16_t exhaustTemp_; // Exhaust temperature uint8_t burnGas_; // Gas on/off uint16_t flameCurr_; // Flame current in micro amps - uint8_t heatPump_; // Boiler pump on/off + uint8_t heatingPump_; // Boiler heating pump on/off uint8_t fanWork_; // Fan on/off uint8_t ignWork_; // Ignition on/off uint8_t heatingActivated_; // Heating activated on the boiler diff --git a/src/devices/mixer.cpp b/src/devices/mixer.cpp index 82ac0a9f4..339b11bf7 100644 --- a/src/devices/mixer.cpp +++ b/src/devices/mixer.cpp @@ -57,17 +57,17 @@ Mixer::Mixer(uint8_t device_type, uint8_t device_id, uint8_t product_id, const s uint8_t tag = TAG_HC1 + hc_ - 1; register_device_value(tag, &id_, DeviceValueType::UINT, nullptr, F("id"), nullptr); // empty full name to prevent being shown in web or console register_device_value(tag, &flowSetTemp_, DeviceValueType::UINT, nullptr, F("flowSetTemp"), F("Setpoint flow temperature"), DeviceValueUOM::DEGREES); - register_device_value(tag, &flowTemp_, DeviceValueType::USHORT, FL_(div10), F("flowTemp"), F("Current flow temperature"), DeviceValueUOM::DEGREES); - register_device_value(tag, &pumpStatus_, DeviceValueType::BOOL, nullptr, F("pumpStatus"), F("Pump status")); - register_device_value(tag, &status_, DeviceValueType::INT, nullptr, F("status"), F("Valve status"), DeviceValueUOM::PERCENT); + register_device_value(tag, &flowTempHc_, DeviceValueType::USHORT, FL_(div10), F("flowTempHc"), F("Flow temperature in assigned hc (TC1)"), DeviceValueUOM::DEGREES); + register_device_value(tag, &pumpStatus_, DeviceValueType::BOOL, nullptr, F("pumpStatus"), F("Pump status in assigned hc (PC1)"), DeviceValueUOM::PUMP); + register_device_value(tag, &status_, DeviceValueType::INT, nullptr, F("valveStatus"), F("Mixing valve actuator in assigned hc (VC1)"), DeviceValueUOM::PERCENT); } else { type_ = Type::WWC; hc_ = device_id - 0x28 + 1; uint8_t tag = TAG_WWC1 + hc_ - 1; register_device_value(tag, &id_, DeviceValueType::UINT, nullptr, F("id"), nullptr); // empty full name to prevent being shown in web or console - register_device_value(tag, &flowTemp_, DeviceValueType::USHORT, FL_(div10), F("flowTemp"), F("Current flow temperature"), DeviceValueUOM::DEGREES); - register_device_value(tag, &pumpStatus_, DeviceValueType::BOOL, nullptr, F("pumpStatus"), F("Pump/Valve status")); - register_device_value(tag, &status_, DeviceValueType::INT, nullptr, F("status"), F("Current status")); + register_device_value(tag, &flowTempHc_, DeviceValueType::USHORT, FL_(div10), F("wwTemp"), F("Current warm water temperature"), DeviceValueUOM::DEGREES); + register_device_value(tag, &pumpStatus_, DeviceValueType::BOOL, nullptr, F("pumpStatus"), F("Pump status in assigned hc (PC1)"), DeviceValueUOM::PUMP); + register_device_value(tag, &status_, DeviceValueType::INT, nullptr, F("tempStatus"), F("Temperature switch in assigned hc (MC1)")); } id_ = product_id; @@ -120,7 +120,7 @@ bool Mixer::publish_ha_config() { // e.g. A0 00 FF 00 01 D7 00 00 00 80 00 00 00 00 03 C5 // A0 0B FF 00 01 D7 00 00 00 80 00 00 00 00 03 80 void Mixer::process_MMPLUSStatusMessage_HC(std::shared_ptr telegram) { - has_update(telegram->read_value(flowTemp_, 3)); // is * 10 + has_update(telegram->read_value(flowTempHc_, 3)); // is * 10 has_update(telegram->read_value(flowSetTemp_, 5)); has_update(telegram->read_bitvalue(pumpStatus_, 0, 0)); has_update(telegram->read_value(status_, 2)); // valve status @@ -130,7 +130,7 @@ void Mixer::process_MMPLUSStatusMessage_HC(std::shared_ptr teleg // e.g. A9 00 FF 00 02 32 02 6C 00 3C 00 3C 3C 46 02 03 03 00 3C // on 0x28 // A8 00 FF 00 02 31 02 35 00 3C 00 3C 3C 46 02 03 03 00 3C // in 0x29 void Mixer::process_MMPLUSStatusMessage_WWC(std::shared_ptr telegram) { - has_update(telegram->read_value(flowTemp_, 0)); // is * 10 + has_update(telegram->read_value(flowTempHc_, 0)); // is * 10 has_update(telegram->read_bitvalue(pumpStatus_, 2, 0)); has_update(telegram->read_value(status_, 11)); // temp status } @@ -148,7 +148,7 @@ void Mixer::process_IPMStatusMessage(std::shared_ptr telegram) { // do we have a mixed circuit if (ismixed == 2) { - has_update(telegram->read_value(flowTemp_, 3)); // is * 10 + has_update(telegram->read_value(flowTempHc_, 3)); // is * 10 has_update(telegram->read_value(status_, 2)); // valve status } @@ -164,7 +164,7 @@ void Mixer::process_MMStatusMessage(std::shared_ptr telegram) { // 0x21 is position 2. 0x20 is typically reserved for the WM10 switch module // see https://github.com/proddy/EMS-ESP/issues/270 and https://github.com/proddy/EMS-ESP/issues/386#issuecomment-629610918 - has_update(telegram->read_value(flowTemp_, 1)); // is * 10 + has_update(telegram->read_value(flowTempHc_, 1)); // is * 10 has_update(telegram->read_bitvalue(pumpStatus_, 3, 2)); // is 0 or 0x64 (100%), check only bit 2 has_update(telegram->read_value(flowSetTemp_, 0)); has_update(telegram->read_value(status_, 4)); // valve status -100 to 100 diff --git a/src/devices/mixer.h b/src/devices/mixer.h index f58efd8bc..1afcd235d 100644 --- a/src/devices/mixer.h +++ b/src/devices/mixer.h @@ -46,7 +46,7 @@ class Mixer : public EMSdevice { }; private: - uint16_t flowTemp_; + uint16_t flowTempHc_; uint8_t pumpStatus_; int8_t status_; uint8_t flowSetTemp_; diff --git a/src/devices/solar.cpp b/src/devices/solar.cpp index 292d8ede7..a4bdc3059 100644 --- a/src/devices/solar.cpp +++ b/src/devices/solar.cpp @@ -51,7 +51,7 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const s register_telegram_type(0x038E, F("SM100Energy"), true, [&](std::shared_ptr t) { process_SM100Energy(t); }); register_telegram_type(0x0391, F("SM100Time"), true, [&](std::shared_ptr t) { process_SM100Time(t); }); - register_mqtt_cmd(F("SM100Tank1MaxTemp"), [&](const char * value, const int8_t id) { return set_SM100Tank1MaxTemp(value, id); }); + register_mqtt_cmd(F("SM100TankBottomMaxTemp"), [&](const char * value, const int8_t id) { return set_SM100TankBottomMaxTemp(value, id); }); } } @@ -72,20 +72,20 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const s id_ = product_id; register_device_value(TAG_NONE, &collectorTemp_, DeviceValueType::SHORT, FL_(div10), F("collectorTemp"), F("Collector temperature (TS1)"), DeviceValueUOM::DEGREES); - register_device_value(TAG_NONE, &tankBottomTemp_, DeviceValueType::SHORT, FL_(div10), F("tankBottomTemp"), F("Tank Bottom temperature (TS2)"), DeviceValueUOM::DEGREES); - register_device_value(TAG_NONE, &tankBottomTemp2_, DeviceValueType::SHORT, FL_(div10), F("tankBottomTemp2"), F("Tank Bottom temperature (TS5)"), DeviceValueUOM::DEGREES); + register_device_value(TAG_NONE, &tankBottomTemp_, DeviceValueType::SHORT, FL_(div10), F("tankBottomTemp"), F("Tank bottom temperature (TS2)"), DeviceValueUOM::DEGREES); + register_device_value(TAG_NONE, &tankBottomTemp2_, DeviceValueType::SHORT, FL_(div10), F("tank2BottomTemp"), F("Second tank bottom temperature (TS5)"), DeviceValueUOM::DEGREES); register_device_value(TAG_NONE, &heatExchangerTemp_, DeviceValueType::SHORT, FL_(div10), F("heatExchangerTemp"), F("Heat exchanger temperature (TS6)"), DeviceValueUOM::DEGREES); - register_device_value(TAG_NONE, &tank1MaxTempCurrent_, DeviceValueType::UINT, nullptr, F("tank1MaxTempCurrent"), F("Maximum Tank temperature")); - register_device_value(TAG_NONE, &solarPumpModulation_, DeviceValueType::UINT, nullptr, F("solarPumpModulation"), F("Solar pump modulation (PS1)"), DeviceValueUOM::PERCENT); + register_device_value(TAG_NONE, &tankBottomMaxTemp_, DeviceValueType::UINT, nullptr, F("tank1MaxTempCurrent"), F("Maximum tank temperature"), DeviceValueUOM::DEGREES); + register_device_value(TAG_NONE, &solarPumpModulation_, DeviceValueType::UINT, nullptr, F("solarPumpModulation"), F("Pump modulation (PS1)"), DeviceValueUOM::PERCENT); register_device_value(TAG_NONE, &cylinderPumpModulation_, DeviceValueType::UINT, nullptr, F("cylinderPumpModulation"), F("Cylinder pump modulation (PS5)"), DeviceValueUOM::PERCENT); - register_device_value(TAG_NONE, &solarPump_, DeviceValueType::BOOL, nullptr, F("solarPump"), F("Solar pump (PS1) active")); + register_device_value(TAG_NONE, &solarPump_, DeviceValueType::BOOL, nullptr, F("solarPump"), F("Pump (PS1)"), DeviceValueUOM::PUMP); register_device_value(TAG_NONE, &valveStatus_, DeviceValueType::BOOL, nullptr, F("valveStatus"), F("Valve status")); register_device_value(TAG_NONE, &tankHeated_, DeviceValueType::BOOL, nullptr, F("tankHeated"), F("Tank heated")); register_device_value(TAG_NONE, &collectorShutdown_, DeviceValueType::BOOL, nullptr, F("collectorShutdown"), F("Collector shutdown")); - register_device_value(TAG_NONE, &pumpWorkMin_, DeviceValueType::TIME, nullptr, F("pumpWorkMin"), F("Pump working time"), DeviceValueUOM::MINUTES); + register_device_value(TAG_NONE, &pumpWorkTime_, DeviceValueType::TIME, nullptr, F("pumpWorkTime"), F("Pump working time"), DeviceValueUOM::MINUTES); register_device_value(TAG_NONE, &energyLastHour_, DeviceValueType::ULONG, FL_(div10), F("energyLastHour"), F("Energy last hour"), DeviceValueUOM::WH); register_device_value(TAG_NONE, &energyTotal_, DeviceValueType::ULONG, FL_(div10), F("energyTotal"), F("Energy total"), DeviceValueUOM::KWH); @@ -124,7 +124,7 @@ void Solar::process_SM10Monitor(std::shared_ptr telegram) { has_update(telegram->read_value(tankBottomTemp_, 5)); // tank bottom temp from SM10, is *10 has_update(telegram->read_value(solarPumpModulation_, 4)); // modulation solar pump has_update(telegram->read_bitvalue(solarPump_, 7, 1)); - has_update(telegram->read_value(pumpWorkMin_, 8, 3)); + has_update(telegram->read_value(pumpWorkTime_, 8, 3)); } /* @@ -144,9 +144,9 @@ void Solar::process_SM100SystemConfig(std::shared_ptr telegram) * e.g. B0 0B FF 00 02 5A 64 05 00 58 14 01 01 32 64 00 00 00 5A 0C */ void Solar::process_SM100SolarCircuitConfig(std::shared_ptr telegram) { - has_update(telegram->read_value(collectorTempMax_, 0, 1)); - has_update(telegram->read_value(tank1MaxTempCurrent_, 3, 1)); - has_update(telegram->read_value(collectorTempMin_, 4, 1)); + has_update(telegram->read_value(collectorMaxTemp_, 0, 1)); + has_update(telegram->read_value(tankBottomMaxTemp_, 3, 1)); + has_update(telegram->read_value(collectorMinTemp_, 4, 1)); has_update(telegram->read_value(solarPumpMode_, 5, 1)); has_update(telegram->read_value(solarPumpMinRPM_, 6, 1)); has_update(telegram->read_value(solarPumpTurnoffDiff_, 7, 1)); @@ -302,7 +302,7 @@ void Solar::process_SM100Energy(std::shared_ptr telegram) { * SM100Time - type 0x0391 EMS+ for pump working time */ void Solar::process_SM100Time(std::shared_ptr telegram) { - has_update(telegram->read_value(pumpWorkMin_, 1, 3)); + has_update(telegram->read_value(pumpWorkTime_, 1, 3)); } /* @@ -320,7 +320,7 @@ void Solar::process_ISM1StatusMessage(std::shared_ptr telegram) } has_update(telegram->read_bitvalue(solarPump_, 8, 0)); // PS1 Solar pump on (1) or off (0) - has_update(telegram->read_value(pumpWorkMin_, 10, 3)); // force to 3 bytes + has_update(telegram->read_value(pumpWorkTime_, 10, 3)); // force to 3 bytes has_update(telegram->read_bitvalue(collectorShutdown_, 9, 0)); // collector shutdown on/off has_update(telegram->read_bitvalue(tankHeated_, 9, 2)); // tank full } @@ -333,7 +333,7 @@ void Solar::process_ISM1Set(std::shared_ptr telegram) { } // set temperature for tank -bool Solar::set_SM100Tank1MaxTemp(const char * value, const int8_t id) { +bool Solar::set_SM100TankBottomMaxTemp(const char * value, const int8_t id) { int temperature; if (!Helpers::value2number(value, temperature)) { return false; diff --git a/src/devices/solar.h b/src/devices/solar.h index ae39a2634..9e5e05e4a 100644 --- a/src/devices/solar.h +++ b/src/devices/solar.h @@ -44,7 +44,7 @@ class Solar : public EMSdevice { uint32_t energyLastHour_; uint32_t energyToday_; uint32_t energyTotal_; - uint32_t pumpWorkMin_; // Total solar pump operating time + uint32_t pumpWorkTime_; // Total solar pump operating time uint8_t tankHeated_; uint8_t collectorShutdown_; // Collector shutdown on/off @@ -60,9 +60,9 @@ class Solar : public EMSdevice { uint8_t solarIsEnabled_; // System enable, 00=no // telegram 0x035A - uint8_t collectorTempMax_; // maximum allowable temperature for collector - uint8_t tank1MaxTempCurrent_; // Current value for max tank temp - uint8_t collectorTempMin_; // minimum allowable temperature for collector + uint8_t collectorMaxTemp_; // maximum allowed collectorTemp array 1 + uint8_t tankBottomMaxTemp_; // Current value for max tank temp + uint8_t collectorMinTemp_; // minimum allowed collectorTemp array 1 uint8_t solarPumpMode_; // 00=off, 01=PWM, 02=10V uint8_t solarPumpMinRPM_; // minimum RPM setting, *5 % uint8_t solarPumpTurnoffDiff_; // solar pump turnoff collector/tank diff @@ -102,7 +102,7 @@ class Solar : public EMSdevice { void process_ISM1Set(std::shared_ptr telegram); - bool set_SM100Tank1MaxTemp(const char * value, const int8_t id); + bool set_SM100TankBottomMaxTemp(const char * value, const int8_t id); }; } // namespace emsesp diff --git a/src/devices/switch.cpp b/src/devices/switch.cpp index 2ba7b2593..dcc4c0d84 100644 --- a/src/devices/switch.cpp +++ b/src/devices/switch.cpp @@ -35,7 +35,7 @@ Switch::Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const register_telegram_type(0x1E, F("WM10TempMessage"), false, [&](std::shared_ptr t) { process_WM10TempMessage(t); }); register_device_value(TAG_NONE, &activated_, DeviceValueType::BOOL, nullptr, F("activated"), F("Activated")); - register_device_value(TAG_NONE, &flowTemp_, DeviceValueType::USHORT, FL_(div10), F("flowTemp"), F("Current flow temperature"), DeviceValueUOM::DEGREES); + register_device_value(TAG_NONE, &flowTempHc_, DeviceValueType::USHORT, FL_(div10), F("flowTempHc"), F("Flow temperature in assigned hc (TC1)"), DeviceValueUOM::DEGREES); register_device_value(TAG_NONE, &status_, DeviceValueType::INT, nullptr, F("status"), F("Status")); register_device_value(TAG_NONE, &id_, DeviceValueType::UINT, nullptr, F("id"), nullptr); // empty full name to prevent being shown in web or console @@ -45,7 +45,7 @@ Switch::Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const // publish HA config bool Switch::publish_ha_config() { // if we don't have valid values don't add it ever again - if (!Helpers::hasValue(flowTemp_)) { + if (!Helpers::hasValue(flowTempHc_)) { return false; } @@ -82,7 +82,7 @@ void Switch::process_WM10SetMessage(std::shared_ptr telegram) { // message 0x9C holds flowtemp and unknown status value // Switch(0x11) -> All(0x00), ?(0x9C), data: 01 BA 00 01 00 void Switch::process_WM10MonitorMessage(std::shared_ptr telegram) { - has_update(telegram->read_value(flowTemp_, 0)); // is * 10 + has_update(telegram->read_value(flowTempHc_, 0)); // is * 10 has_update(telegram->read_value(status_, 2)); // has_update(telegram->read_value(status2_, 3)); // unknown } @@ -90,7 +90,7 @@ void Switch::process_WM10MonitorMessage(std::shared_ptr telegram // message 0x1E flow temperature, same as in 9C, published often, republished also by boiler UBAFast 0x18 // Switch(0x11) -> Boiler(0x08), ?(0x1E), data: 01 BA void Switch::process_WM10TempMessage(std::shared_ptr telegram) { - has_update(telegram->read_value(flowTemp_, 0)); // is * 10 + has_update(telegram->read_value(flowTempHc_, 0)); // is * 10 } } // namespace emsesp \ No newline at end of file diff --git a/src/devices/switch.h b/src/devices/switch.h index c500717de..664553445 100644 --- a/src/devices/switch.h +++ b/src/devices/switch.h @@ -36,7 +36,7 @@ class Switch : public EMSdevice { void process_WM10MonitorMessage(std::shared_ptr telegram); void process_WM10TempMessage(std::shared_ptr telegram); - uint16_t flowTemp_; + uint16_t flowTempHc_; uint8_t status_; uint8_t activated_; uint8_t id_; diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 64cda4920..c3f6d98be 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -229,6 +229,7 @@ std::shared_ptr Thermostat::heating_circuit(const ui // returns pointer to the HeatingCircuit or nullptr if it can't be found // if its a new one, the object will be created and also the fetch flags set std::shared_ptr Thermostat::heating_circuit(std::shared_ptr telegram) { + // look through the Monitor and Set arrays to see if there is a match uint8_t hc_num = 0; bool toggle_ = false; @@ -559,6 +560,9 @@ std::string Thermostat::mode_tostring(uint8_t mode) { case HeatingCircuit::Mode::ROOMINFLUENCE: return read_flash_string(F("roominfluence")); break; + case HeatingCircuit::Mode::FLOWOFFSET: + return read_flash_string(F("flowtempoffset")); + break; default: case HeatingCircuit::Mode::UNKNOWN: return read_flash_string(F("unknown")); @@ -809,8 +813,8 @@ void Thermostat::process_RC300Curve(std::shared_ptr telegram) { // types 0x31B (and 0x31C?) void Thermostat::process_RC300WWtemp(std::shared_ptr telegram) { - has_update(telegram->read_value(wwTemp_, 0)); - has_update(telegram->read_value(wwTempLow_, 1)); + has_update(telegram->read_value(wwSetTemp_, 0)); + has_update(telegram->read_value(wwSetTempLow_, 1)); } // type 02F5 @@ -1605,58 +1609,6 @@ bool Thermostat::set_program(const char * value, const int8_t id) { return true; } -// sets the thermostat temp, where mode is a string -bool Thermostat::set_temperature(const float temperature, const std::string & mode, const uint8_t hc_num) { - if (mode_tostring(HeatingCircuit::Mode::MANUAL) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::MANUAL, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::AUTO) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::AUTO, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::DAY) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::DAY, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::NIGHT) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::NIGHT, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::COMFORT) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::COMFORT, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::HEAT) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::HEAT, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::ECO) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::ECO, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::NOFROST) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::NOFROST, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::SUMMER) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::SUMMER, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::HOLIDAY) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::HOLIDAY, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::OFFSET) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::OFFSET, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::DESIGN) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::DESIGN, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::MINFLOW) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::MINFLOW, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::MAXFLOW) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::MAXFLOW, hc_num); - } - if (mode_tostring(HeatingCircuit::Mode::ROOMINFLUENCE) == mode) { - return set_temperature(temperature, HeatingCircuit::Mode::ROOMINFLUENCE, hc_num); - } - - LOG_WARNING(F("Set temperature: Invalid mode")); - return false; -} - // Set the temperature of the thermostat // the id passed into this function is the heating circuit number bool Thermostat::set_temperature(const float temperature, const uint8_t mode, const uint8_t hc_num) { @@ -2011,8 +1963,8 @@ void Thermostat::add_commands() { register_mqtt_cmd(F("summermode"), [&](const char * value, const int8_t id) { return set_summermode(value, id); }); register_mqtt_cmd(F("summertemp"), [&](const char * value, const int8_t id) { return set_summertemp(value, id); }); register_mqtt_cmd(F("wwmode"), [&](const char * value, const int8_t id) { return set_wwmode(value, id); }); - register_mqtt_cmd(F("wwtemp"), [&](const char * value, const int8_t id) { return set_wwtemp(value, id); }); - register_mqtt_cmd(F("wwtemplow"), [&](const char * value, const int8_t id) { return set_wwtemplow(value, id); }); + register_mqtt_cmd(F("wwsettemp"), [&](const char * value, const int8_t id) { return set_wwtemp(value, id); }); + register_mqtt_cmd(F("wwsettemplow"), [&](const char * value, const int8_t id) { return set_wwtemplow(value, id); }); register_mqtt_cmd(F("wwonetime"), [&](const char * value, const int8_t id) { return set_wwonetime(value, id); }); register_mqtt_cmd(F("wwcircmode"), [&](const char * value, const int8_t id) { return set_wwcircmode(value, id); }); register_mqtt_cmd(F("building"), [&](const char * value, const int8_t id) { return set_building(value, id); }); @@ -2084,23 +2036,23 @@ void Thermostat::register_device_values() { // RC30 only if (model == EMSdevice::EMS_DEVICE_FLAG_RC30_1) { - register_device_value(TAG_NONE, &ibaMainDisplay_, DeviceValueType::ENUM, FL_(enum_ibaMainDisplay), F("ibaMainDisplay"), F("Display")); - register_device_value(TAG_NONE, &ibaLanguage_, DeviceValueType::ENUM, FL_(enum_ibaLanguage), F("ibaLanguage"), F("Language")); - register_device_value(TAG_NONE, &ibaClockOffset_, DeviceValueType::UINT, nullptr, F("ibaClockOffset"), F("Clock offset")); // offset (in sec) to clock, 0xff=-1s, 0x02=2s + register_device_value(TAG_NONE, &ibaMainDisplay_, DeviceValueType::ENUM, FL_(enum_ibaMainDisplay), F("display"), F("Display")); + register_device_value(TAG_NONE, &ibaLanguage_, DeviceValueType::ENUM, FL_(enum_ibaLanguage), F("language"), F("Language")); + register_device_value(TAG_NONE, &ibaClockOffset_, DeviceValueType::UINT, nullptr, F("offsetclock"), F("Clock offset")); // offset (in sec) to clock, 0xff=-1s, 0x02=2s } // RC300 and RC100 if (model == EMS_DEVICE_FLAG_RC300 || model == EMS_DEVICE_FLAG_RC100) { register_device_value(TAG_NONE, &floordrystatus_, DeviceValueType::ENUM, FL_(enum_floordrystatus), F("floordry"), F("Floor drying")); - register_device_value(TAG_NONE, &dampedoutdoortemp2_, DeviceValueType::SHORT, FL_(div10), F("dampedtemp"), F("Damped outdoor temperature"), DeviceValueUOM::DEGREES); + register_device_value(TAG_NONE, &dampedoutdoortemp2_, DeviceValueType::SHORT, FL_(div10), F("dampedoutdoortemp"), F("Damped outdoor temperature"), DeviceValueUOM::DEGREES); register_device_value(TAG_NONE, &floordrytemp_, DeviceValueType::UINT, nullptr, F("floordrytemp"), F("Floor drying temperature"), DeviceValueUOM::DEGREES); register_device_value(TAG_NONE, &ibaBuildingType_, DeviceValueType::ENUM, FL_(enum_ibaBuildingType), F("building"), F("Building")); - register_device_value(TAG_NONE, &wwTemp_, DeviceValueType::UINT, nullptr, F("wwTemp"), F("Warm water high temperature"), DeviceValueUOM::DEGREES); + register_device_value(TAG_NONE, &wwSetTemp_, DeviceValueType::UINT, nullptr, F("wwsettemp"), F("Warm water set temperature"), DeviceValueUOM::DEGREES); register_device_value(TAG_NONE, &wwMode_, DeviceValueType::ENUM, FL_(enum_wwMode), F("wwmode"), F("Warm water mode")); - register_device_value(TAG_NONE, &wwTempLow_, DeviceValueType::UINT, nullptr, F("wwTempLow"), F("Warm water low temperature"), DeviceValueUOM::DEGREES); + register_device_value(TAG_NONE, &wwSetTempLow_, DeviceValueType::UINT, nullptr, F("wwsettemplow"), F("Warm water set temperature low"), DeviceValueUOM::DEGREES); register_device_value(TAG_NONE, &wwCircMode_, DeviceValueType::ENUM, FL_(enum_wwCircMode), F("wwcircmode"), F("Warm water circulation mode")); - register_device_value(TAG_NONE, &wwExtra1_, DeviceValueType::UINT, nullptr, F("wwExtra1"), F("Warm water circuit 1 extra"), DeviceValueUOM::DEGREES); - register_device_value(TAG_NONE, &wwExtra2_, DeviceValueType::UINT, nullptr, F("wwExtra2"), F("Warm water circuit 2 extra"), DeviceValueUOM::DEGREES); + register_device_value(TAG_NONE, &wwExtra1_, DeviceValueType::UINT, nullptr, F("wwextra1"), F("Warm water circuit 1 extra"), DeviceValueUOM::DEGREES); + register_device_value(TAG_NONE, &wwExtra2_, DeviceValueType::UINT, nullptr, F("wwextra2"), F("Warm water circuit 2 extra"), DeviceValueUOM::DEGREES); } // RC30 and RC35 diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index 11b2662b9..3f7aca05b 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -159,8 +159,8 @@ class Thermostat : public EMSdevice { uint8_t wwMode_; uint8_t wwCircPump_; uint8_t wwCircMode_; - uint8_t wwTemp_; - uint8_t wwTempLow_; + uint8_t wwSetTemp_; + uint8_t wwSetTempLow_; std::vector> heating_circuits_; // each thermostat can have multiple heating circuits @@ -287,7 +287,6 @@ class Thermostat : public EMSdevice { bool set_mode_n(const uint8_t mode, const uint8_t hc_num); bool set_temperature_value(const char * value, const int8_t id, const uint8_t mode); - bool set_temperature(const float temperature, const std::string & mode, const uint8_t hc_num); bool set_temperature(const float temperature, const uint8_t mode, const uint8_t hc_num); // set functions - these use the id/hc diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 6ef018016..34cddecee 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -56,7 +56,7 @@ static const __FlashStringHelper * const DeviceValueTAG_s[] PROGMEM = { }; const std::string EMSdevice::uom_to_string(uint8_t uom) { - if (uom == DeviceValueUOM::NONE) { + if (uom == DeviceValueUOM::NONE || uom >= DeviceValueUOM::PUMP) { return std::string{}; } return uuid::read_flash_string(DeviceValueUOM_s[uom - 1]); // offset by 1 to account for NONE @@ -602,7 +602,11 @@ bool EMSdevice::generate_values_json(JsonObject & root, const uint8_t tag_filter // handle ENUMs else if ((dv.type == DeviceValueType::ENUM) && Helpers::hasValue(*(uint8_t *)(dv.value_p))) { if (*(uint8_t *)(dv.value_p) < dv.options_size) { - json[name] = dv.options[*(uint8_t *)(dv.value_p)]; + if (Mqtt::bool_format() == BOOL_FORMAT_10) { + json[name] = (uint8_t)(*(uint8_t *)(dv.value_p)); + } else { + json[name] = dv.options[*(uint8_t *)(dv.value_p)]; + } has_value = true; } } diff --git a/src/emsdevice.h b/src/emsdevice.h index c814aa0ed..4109c1cf9 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -31,12 +31,14 @@ namespace emsesp { // Home Assistant icons (https://materialdesignicons.com/) -MAKE_PSTR(icontemperature, "mdi:temperature-celsius") +// MAKE_PSTR(icontemperature, "mdi:temperature-celsius") +MAKE_PSTR(icontemperature, "mdi:coolant-temperature") MAKE_PSTR(iconpercent, "mdi:percent-outline") MAKE_PSTR(iconfire, "mdi:fire") MAKE_PSTR(iconfan, "mdi:fan") MAKE_PSTR(iconflame, "mdi:flash") MAKE_PSTR(iconvalve, "mdi:valve") +MAKE_PSTR(iconpump, "mdi:pump") enum DeviceValueType : uint8_t { BOOL, @@ -73,8 +75,8 @@ enum DeviceValueUOM : uint8_t { HOURS, MINUTES, UA, - BAR - + BAR, + PUMP }; // TAG mapping - maps to DeviceValueTAG_s in emsdevice.cpp diff --git a/src/shower.cpp b/src/shower.cpp index 6614e5f05..971a43b37 100644 --- a/src/shower.cpp +++ b/src/shower.cpp @@ -108,7 +108,7 @@ void Shower::send_mqtt_stat(bool state) { StaticJsonDocument doc; doc["name"] = FJSON("Shower Active"); doc["uniq_id"] = FJSON("shower_active"); - doc["~"] = EMSESP::system_.hostname(); // default ems-esp + doc["~"] = Mqtt::base(); // default ems-esp doc["stat_t"] = FJSON("~/shower_active"); JsonObject dev = doc.createNestedObject("dev"); JsonArray ids = dev.createNestedArray("ids"); @@ -152,11 +152,7 @@ void Shower::publish_values() { // only publish shower duration if there is a value if (duration_ > SHOWER_MIN_DURATION) { - char buffer[16] = {0}; - strlcpy(s, Helpers::itoa(buffer, (uint8_t)((duration_ / (1000 * 60)) % 60), 10), 50); - strlcat(s, " minutes and ", 50); - strlcat(s, Helpers::itoa(buffer, (uint8_t)((duration_ / 1000) % 60), 10), 50); - strlcat(s, " seconds", 50); + snprintf_P(s, 50, PSTR("%d minutes and %d seconds"), (uint8_t)(duration_ / 60000), (uint8_t)((duration_ / 1000) % 60)); doc["duration"] = s; }