Skip to content

Commit

Permalink
autoformatting, check HS circuits
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Mar 6, 2022
1 parent 7168f6c commit 6bbe268
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 67 deletions.
46 changes: 36 additions & 10 deletions src/devices/solar.cpp
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -252,19 +263,34 @@ 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,
nullptr,
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,
Expand Down
14 changes: 2 additions & 12 deletions src/devices/thermostat.cpp
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
12 changes: 5 additions & 7 deletions src/emsdevice.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
}
Expand Down
66 changes: 33 additions & 33 deletions src/emsdevicevalue.cpp
Expand Up @@ -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"

};

Expand Down
6 changes: 2 additions & 4 deletions src/emsesp.cpp
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/helpers.cpp
Expand Up @@ -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];
Expand Down

0 comments on commit 6bbe268

Please sign in to comment.