From 6bbe2687ef40f6893fd71d47983fc2786de36f54 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Wed, 2 Mar 2022 13:25:35 +0100 Subject: [PATCH] autoformatting, check HS circuits --- src/devices/solar.cpp | 46 ++++++++++++++++++++------ src/devices/thermostat.cpp | 14 ++------ src/emsdevice.cpp | 12 +++---- src/emsdevicevalue.cpp | 66 +++++++++++++++++++------------------- src/emsesp.cpp | 6 ++-- src/helpers.cpp | 1 - 6 files changed, 78 insertions(+), 67 deletions(-) diff --git a/src/devices/solar.cpp b/src/devices/solar.cpp index 1b5ab0224..b461c32e7 100644 --- a/src/devices/solar.cpp +++ b/src/devices/solar.cpp @@ -139,8 +139,13 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const c if (flags == EMSdevice::EMS_DEVICE_FLAG_SM10) { register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &solarPumpMod_, DeviceValueType::UINT, nullptr, FL_(solarPumpMod), DeviceValueUOM::PERCENT); - register_device_value( - DeviceValueTAG::TAG_DEVICE_DATA, &solarPumpMinMod_, DeviceValueType::UINT, nullptr, FL_(pumpMinMod), DeviceValueUOM::PERCENT, MAKE_CF_CB(set_PumpMinMod)); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, + &solarPumpMinMod_, + DeviceValueType::UINT, + nullptr, + FL_(pumpMinMod), + DeviceValueUOM::PERCENT, + MAKE_CF_CB(set_PumpMinMod)); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &solarPumpTurnonDiff_, DeviceValueType::UINT, @@ -157,7 +162,8 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const c MAKE_CF_CB(set_TurnoffDiff)); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &solarPower_, DeviceValueType::SHORT, nullptr, FL_(solarPower), DeviceValueUOM::W); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &energyLastHour_, DeviceValueType::ULONG, FL_(div10), FL_(energyLastHour), DeviceValueUOM::WH); - register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &maxFlow_, DeviceValueType::UINT, FL_(div10), FL_(maxFlow), DeviceValueUOM::LMIN, MAKE_CF_CB(set_SM10MaxFlow)); + register_device_value( + DeviceValueTAG::TAG_DEVICE_DATA, &maxFlow_, DeviceValueType::UINT, FL_(div10), FL_(maxFlow), DeviceValueUOM::LMIN, MAKE_CF_CB(set_SM10MaxFlow)); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA_WW, &wwMinTemp_, DeviceValueType::UINT, @@ -219,7 +225,12 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const c register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &solarPump2_, DeviceValueType::BOOL, nullptr, FL_(solarPump2), DeviceValueUOM::NONE); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &solarPump2Mod_, DeviceValueType::UINT, nullptr, FL_(solarPump2Mod), DeviceValueUOM::PERCENT); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &cylBottomTemp2_, DeviceValueType::SHORT, FL_(div10), FL_(cyl2BottomTemp), DeviceValueUOM::DEGREES); - register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &heatExchangerTemp_, DeviceValueType::SHORT, FL_(div10), FL_(heatExchangerTemp), DeviceValueUOM::DEGREES); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, + &heatExchangerTemp_, + DeviceValueType::SHORT, + FL_(div10), + FL_(heatExchangerTemp), + DeviceValueUOM::DEGREES); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &cylPumpMod_, DeviceValueType::UINT, nullptr, FL_(cylPumpMod), DeviceValueUOM::PERCENT); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &valveStatus_, DeviceValueType::BOOL, nullptr, FL_(valveStatus), DeviceValueUOM::NONE); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &cylHeated_, DeviceValueType::BOOL, nullptr, FL_(cylHeated), DeviceValueUOM::NONE); @@ -252,8 +263,13 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const c FL_(heatTransferSystem), DeviceValueUOM::NONE, MAKE_CF_CB(set_heatTransferSystem)); - register_device_value( - DeviceValueTAG::TAG_DEVICE_DATA, &externalCyl_, DeviceValueType::BOOL, nullptr, FL_(externalCyl), DeviceValueUOM::NONE, MAKE_CF_CB(set_externalCyl)); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, + &externalCyl_, + DeviceValueType::BOOL, + nullptr, + FL_(externalCyl), + DeviceValueUOM::NONE, + MAKE_CF_CB(set_externalCyl)); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &thermalDisinfect_, DeviceValueType::BOOL, @@ -261,10 +277,20 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const c FL_(thermalDisinfect), DeviceValueUOM::NONE, MAKE_CF_CB(set_thermalDisinfect)); - register_device_value( - DeviceValueTAG::TAG_DEVICE_DATA, &heatMetering_, DeviceValueType::BOOL, nullptr, FL_(heatMetering), DeviceValueUOM::NONE, MAKE_CF_CB(set_heatMetering)); - register_device_value( - DeviceValueTAG::TAG_DEVICE_DATA, &solarIsEnabled_, DeviceValueType::BOOL, nullptr, FL_(activated), DeviceValueUOM::NONE, MAKE_CF_CB(set_solarEnabled)); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, + &heatMetering_, + DeviceValueType::BOOL, + nullptr, + FL_(heatMetering), + DeviceValueUOM::NONE, + MAKE_CF_CB(set_heatMetering)); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, + &solarIsEnabled_, + DeviceValueType::BOOL, + nullptr, + FL_(activated), + DeviceValueUOM::NONE, + MAKE_CF_CB(set_solarEnabled)); // telegram 0x035A register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 654807985..f8f505aa5 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -2887,12 +2887,7 @@ void Thermostat::register_device_values() { FL_(enum_ibaMainDisplay), FL_(ibaMainDisplay), DeviceValueUOM::NONE); - register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, - &ibaLanguage_, - DeviceValueType::ENUM, - FL_(enum_ibaLanguage), - FL_(ibaLanguage), - DeviceValueUOM::NONE); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &ibaLanguage_, DeviceValueType::ENUM, FL_(enum_ibaLanguage), FL_(ibaLanguage), DeviceValueUOM::NONE); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &ibaClockOffset_, DeviceValueType::INT, @@ -2908,12 +2903,7 @@ void Thermostat::register_device_values() { FL_(enum_ibaMainDisplay), FL_(ibaMainDisplay), DeviceValueUOM::NONE); - register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, - &ibaLanguage_, - DeviceValueType::ENUM, - FL_(enum_ibaLanguage), - FL_(ibaLanguage), - DeviceValueUOM::NONE); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &ibaLanguage_, DeviceValueType::ENUM, FL_(enum_ibaLanguage), FL_(ibaLanguage), DeviceValueUOM::NONE); register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &ibaClockOffset_, DeviceValueType::INT, diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 5d667d365..db2c5586a 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -293,7 +293,7 @@ bool EMSdevice::is_fetch(uint16_t telegram_id) { bool EMSdevice::has_tag(const uint8_t tag) { for (const auto & dv : devicevalues_) { if (dv.tag == tag && tag >= DeviceValueTAG::TAG_HC1) { - return true; + return true; } } return false; @@ -505,7 +505,7 @@ void EMSdevice::register_device_value(uint8_t tag, flags |= CommandFlag::MQTT_SUB_FLAG_HC; } else if (tag >= DeviceValueTAG::TAG_WWC1 && tag <= DeviceValueTAG::TAG_WWC4) { flags |= CommandFlag::MQTT_SUB_FLAG_WWC; - } else if (tag == DeviceValueTAG::TAG_DEVICE_DATA_WW) { + } else if (tag == DeviceValueTAG::TAG_DEVICE_DATA_WW || tag == DeviceValueTAG::TAG_BOILER_DATA_WW) { flags |= CommandFlag::MQTT_SUB_FLAG_WW; } @@ -554,7 +554,7 @@ void EMSdevice::publish_value(void * value_p) { if (dv.value_p == value_p && dv.has_state(DeviceValueState::DV_VISIBLE)) { char topic[Mqtt::MQTT_TOPIC_MAX_SIZE]; if (Mqtt::publish_single2cmd()) { - if ((dv.tag >= DeviceValueTAG::TAG_HC1 && dv.tag <= DeviceValueTAG::TAG_WWC4)) { + if (dv.tag >= DeviceValueTAG::TAG_HC1) { snprintf(topic, sizeof(topic), "%s/%s/%s", @@ -903,11 +903,9 @@ bool EMSdevice::get_value_info(JsonObject & output, const char * cmd, const int8 JsonObject json = output; int8_t tag = id; - // check if we have hc or wwc - if (id >= 1 && id <= 8) { + // check if we have hc or wwc or hs + if (id >= 1 && id <= 29) { tag = DeviceValueTAG::TAG_HC1 + id - 1; - } else if (id >= 9 && id <= 12) { - tag = DeviceValueTAG::TAG_WWC1 + id - 9; } else if (id != -1) { return false; // error } diff --git a/src/emsdevicevalue.cpp b/src/emsdevicevalue.cpp index bb007a244..5ca795666 100644 --- a/src/emsdevicevalue.cpp +++ b/src/emsdevicevalue.cpp @@ -53,39 +53,39 @@ const __FlashStringHelper * DeviceValue::DeviceValueUOM_s[] __attribute__((__ali // must be an int of 4 bytes, 32bit aligned const __FlashStringHelper * const DeviceValue::DeviceValueTAG_s[] PROGMEM = { - F_(tag_none), // "" - F_(tag_heartbeat), // "" - F_(tag_boiler_data_ww), // "dhw" - F_(tag_device_data), // "" - F_(tag_device_data_ww), // "dhw" - F_(tag_hc1), // "hc1" - F_(tag_hc2), // "hc2" - F_(tag_hc3), // "hc3" - F_(tag_hc4), // "hc4" - F_(tag_hc5), // "hc5" - F_(tag_hc6), // "hc6" - F_(tag_hc7), // "hc7" - F_(tag_hc8), // "hc8" - F_(tag_wwc1), // "wwc1" - F_(tag_wwc2), // "Wwc2" - F_(tag_wwc3), // "wwc3" - F_(tag_wwc4), // "wwc4" - F_(tag_hs1), // "hs1" - F_(tag_hs2), // "hs2" - F_(tag_hs3), // "hs3" - F_(tag_hs4), // "hs4" - F_(tag_hs5), // "hs5" - F_(tag_hs6), // "hs6" - F_(tag_hs7), // "hs7" - F_(tag_hs8), // "hs8" - F_(tag_hs9), // "hs9" - F_(tag_hs10), // "hs10" - F_(tag_hs11), // "hs11" - F_(tag_hs12), // "hs12" - F_(tag_hs13), // "hs13" - F_(tag_hs14), // "hs14" - F_(tag_hs15), // "hs15" - F_(tag_hs16) // "hs16" + F_(tag_none), // "" + F_(tag_heartbeat), // "" + F_(tag_boiler_data_ww), // "dhw" + F_(tag_device_data), // "" + F_(tag_device_data_ww), // "dhw" + F_(tag_hc1), // "hc1" + F_(tag_hc2), // "hc2" + F_(tag_hc3), // "hc3" + F_(tag_hc4), // "hc4" + F_(tag_hc5), // "hc5" + F_(tag_hc6), // "hc6" + F_(tag_hc7), // "hc7" + F_(tag_hc8), // "hc8" + F_(tag_wwc1), // "wwc1" + F_(tag_wwc2), // "Wwc2" + F_(tag_wwc3), // "wwc3" + F_(tag_wwc4), // "wwc4" + F_(tag_hs1), // "hs1" + F_(tag_hs2), // "hs2" + F_(tag_hs3), // "hs3" + F_(tag_hs4), // "hs4" + F_(tag_hs5), // "hs5" + F_(tag_hs6), // "hs6" + F_(tag_hs7), // "hs7" + F_(tag_hs8), // "hs8" + F_(tag_hs9), // "hs9" + F_(tag_hs10), // "hs10" + F_(tag_hs11), // "hs11" + F_(tag_hs12), // "hs12" + F_(tag_hs13), // "hs13" + F_(tag_hs14), // "hs14" + F_(tag_hs15), // "hs15" + F_(tag_hs16) // "hs16" }; diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 1acf41824..401ebc48d 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -1103,10 +1103,8 @@ bool EMSESP::command_commands(uint8_t device_type, JsonObject & output, const in bool EMSESP::command_info(uint8_t device_type, JsonObject & output, const int8_t id, const uint8_t output_target) { bool has_value = false; uint8_t tag; - if (id >= 1 && id <= 8) { - tag = DeviceValueTAG::TAG_HC1 + id - 1; - } else if (id >= 9 && id <= 12) { - tag = DeviceValueTAG::TAG_WWC1 + id - 9; + if (id >= 1 && id <= 29) { + tag = DeviceValueTAG::TAG_HC1 + id - 1; // this sets also WWC and HS } else if (id == -1 || id == 0) { tag = DeviceValueTAG::TAG_NONE; } else { diff --git a/src/helpers.cpp b/src/helpers.cpp index 108b5783f..c405630ef 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -52,7 +52,6 @@ char * Helpers::hextoa(char * result, const uint16_t value) { return result; } - // same as above but to a hex string std::string Helpers::hextoa(const uint16_t value, bool prefix) { char buf[5];