sonar fixes

This commit is contained in:
proddy
2022-03-05 14:25:35 +01:00
parent e247b9e5f9
commit c1edbbf047
37 changed files with 639 additions and 610 deletions

View File

@@ -532,7 +532,7 @@ void Boiler::process_UBAParameterWW(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, wwDisinfectionTemp_, 8);
has_bitupdate(telegram, wwChargeType_, 10, 0); // 0 = charge pump, 0xff = 3-way valve
uint8_t wwComfort;
uint8_t wwComfort = EMS_VALUE_UINT_NOTSET;
telegram->read_value(wwComfort, 9);
if (wwComfort == 0) {
wwComfort = 0; // Hot
@@ -594,7 +594,7 @@ void Boiler::process_UBAMonitorFastPlus(std::shared_ptr<const Telegram> telegram
// read 3 char service code / installation status as appears on the display
if ((telegram->message_length > 3) && (telegram->offset == 0)) {
char serviceCode[4];
char serviceCode[4] = {0};
telegram->read_value(serviceCode[0], 1);
serviceCode[0] = (serviceCode[0] == (char)0xF0) ? '~' : serviceCode[0];
telegram->read_value(serviceCode[1], 2);
@@ -878,19 +878,19 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr<const Telegram> telegram) {
if (telegram->message_data[4] & 0x80) { // valid date
static uint32_t lastCodeDate_ = 0; // last code date
char code[3];
uint16_t codeNo;
code[0] = telegram->message_data[0];
code[1] = telegram->message_data[1];
code[2] = 0;
char code[3] = {0};
uint16_t codeNo = EMS_VALUE_SHORT_NOTSET;
code[0] = telegram->message_data[0];
code[1] = telegram->message_data[1];
code[2] = 0;
telegram->read_value(codeNo, 2);
uint16_t year = (telegram->message_data[4] & 0x7F) + 2000;
uint8_t month = telegram->message_data[5];
uint8_t day = telegram->message_data[7];
uint8_t hour = telegram->message_data[6];
uint8_t min = telegram->message_data[8];
uint32_t date = (year - 2000) * 535680UL + month * 44640UL + day * 1440UL + hour * 60 + min;
uint16_t duration;
uint16_t year = (telegram->message_data[4] & 0x7F) + 2000;
uint8_t month = telegram->message_data[5];
uint8_t day = telegram->message_data[7];
uint8_t hour = telegram->message_data[6];
uint8_t min = telegram->message_data[8];
uint32_t date = (year - 2000) * 535680UL + month * 44640UL + day * 1440UL + hour * 60 + min;
uint16_t duration = EMS_VALUE_SHORT_NOTSET;
telegram->read_value(duration, 9);
// store only the newest code from telegrams 10 and 11
if (date > lastCodeDate_) {
@@ -908,12 +908,12 @@ void Boiler::process_UBAErrorMessage2(std::shared_ptr<const Telegram> telegram)
return;
}
char code[sizeof(lastCode_)];
uint16_t codeNo;
code[0] = telegram->message_data[5];
code[1] = telegram->message_data[6];
code[2] = telegram->message_data[7];
code[3] = 0;
char code[sizeof(lastCode_)] = {0};
uint16_t codeNo = EMS_VALUE_SHORT_NOTSET;
code[0] = telegram->message_data[5];
code[1] = telegram->message_data[6];
code[2] = telegram->message_data[7];
code[3] = 0;
telegram->read_value(codeNo, 8);
// check for valid date, https://github.com/emsesp/EMS-ESP32/issues/204
@@ -1486,8 +1486,12 @@ bool Boiler::set_reset(const char * value, const int8_t id) {
return false;
}
//maintenance
// maintenance
bool Boiler::set_maintenance(const char * value, const int8_t id) {
if (value == nullptr) {
return false;
}
std::string s;
if (Helpers::value2string(value, s)) {
if (s == Helpers::toLower(read_flash_string(F_(reset)))) {
@@ -1549,7 +1553,7 @@ bool Boiler::set_maintenancetime(const char * value, const int8_t id) {
//maintenance
bool Boiler::set_maintenancedate(const char * value, const int8_t id) {
if (strlen(value) == 10) { // date
if ((value != nullptr) && strlen(value) == 10) { // date
uint8_t day = (value[0] - '0') * 10 + (value[1] - '0');
uint8_t month = (value[3] - '0') * 10 + (value[4] - '0');
uint8_t year = (uint8_t)(Helpers::atoint(&value[6]) - 2000);

View File

@@ -370,7 +370,7 @@ std::shared_ptr<Thermostat::HeatingCircuit> Thermostat::heating_circuit(std::sha
}
// add the HVAC/Climate HA component for the HC
void Thermostat::add_ha_climate(std::shared_ptr<HeatingCircuit> hc) {
void Thermostat::add_ha_climate(std::shared_ptr<HeatingCircuit> hc) const {
if (!Mqtt::ha_enabled()) {
hc->climate = EMS_VALUE_UINT_NOTSET;
return;
@@ -1274,18 +1274,18 @@ void Thermostat::process_RCErrorMessage(std::shared_ptr<const Telegram> telegram
// data: displaycode(2), errornumber(2), year, month, hour, day, minute, duration(2), src-addr
if (telegram->message_data[4] & 0x80) { // valid date
char code[sizeof(lastCode_)];
uint16_t codeNo = EMS_VALUE_USHORT_NOTSET;
code[0] = telegram->message_data[0];
code[1] = telegram->message_data[1];
code[2] = 0;
char code[sizeof(lastCode_)] = {0};
uint16_t codeNo = EMS_VALUE_USHORT_NOTSET;
code[0] = telegram->message_data[0];
code[1] = telegram->message_data[1];
code[2] = 0;
telegram->read_value(codeNo, 2);
uint16_t year = (telegram->message_data[4] & 0x7F) + 2000;
uint8_t month = telegram->message_data[5];
uint8_t day = telegram->message_data[7];
uint8_t hour = telegram->message_data[6];
uint8_t min = telegram->message_data[8];
uint16_t duration;
uint16_t year = (telegram->message_data[4] & 0x7F) + 2000;
uint8_t month = telegram->message_data[5];
uint8_t day = telegram->message_data[7];
uint8_t hour = telegram->message_data[6];
uint8_t min = telegram->message_data[8];
uint16_t duration = EMS_VALUE_SHORT_NOTSET;
telegram->read_value(duration, 9);
snprintf(&code[2], sizeof(code) - 2, "(%d) %02d.%02d.%d %02d:%02d (%d min)", codeNo, day, month, year, hour, min, duration);
has_update(lastCode_, code, sizeof(lastCode_));
@@ -1329,7 +1329,7 @@ bool Thermostat::set_calinttemp(const char * value, const int8_t id) {
return false;
}
int8_t t = (int8_t)(ct * 10);
auto t = (int8_t)(ct * 10);
LOG_DEBUG(F("Calibrating internal temperature to %d.%d C"), t / 10, t < 0 ? -t % 10 : t % 10);
if (model() == EMS_DEVICE_FLAG_RC10) {
@@ -1696,9 +1696,11 @@ bool Thermostat::set_wwCircProg(const char * value, const int8_t id) {
bool Thermostat::set_holiday(const char * value, const int8_t id, const bool vacation) {
uint8_t hc_num = (id == -1) ? AUTO_HEATING_CIRCUIT : id;
std::shared_ptr<Thermostat::HeatingCircuit> hc = heating_circuit(hc_num);
if (hc == nullptr) {
if ((hc == nullptr) || (value == nullptr)) {
return false;
}
if (strlen(value) != 21) {
return false;
}
@@ -1843,7 +1845,7 @@ bool Thermostat::set_roominfl_factor(const char * value, const int8_t id) {
// sets the thermostat working mode, where mode is a string
// converts string mode to HeatingCircuit::Mode
bool Thermostat::set_mode(const char * value, const int8_t id) {
if (strlen(value) >= 20) {
if ((value == nullptr) || (strlen(value) >= 20)) {
return false;
}
@@ -2171,7 +2173,7 @@ bool Thermostat::set_switchtime(const char * value, const uint16_t type_id, char
}
const char * s_mode = doc["mode"];
const char * s_time = doc["time"];
if ((model() == EMS_DEVICE_FLAG_RC35 || model() == EMS_DEVICE_FLAG_RC30_N)) {
if (model() == EMS_DEVICE_FLAG_RC35 || model() == EMS_DEVICE_FLAG_RC30_N) {
bool b;
if (Helpers::value2bool(s_mode, b)) {
on = b ? 1 : 0;
@@ -2386,6 +2388,8 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
offset = 4;
}
break;
default:
break;
}
} else if (model == EMS_DEVICE_FLAG_RC20) {
switch (mode) {
@@ -2419,6 +2423,8 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
offset = EMS_OFFSET_RC20Set_temp_auto;
}
break;
default:
break;
}
} else if (model == EMS_DEVICE_FLAG_RC30) {
@@ -3352,6 +3358,8 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
register_device_value(tag, &hc->program, DeviceValueType::ENUM, FL_(enum_progMode4), FL_(program), DeviceValueUOM::NONE, MAKE_CF_CB(set_program));
register_device_value(tag, &hc->remotetemp, DeviceValueType::SHORT, FL_(div10), FL_(remotetemp), DeviceValueUOM::DEGREES);
break;
default:
break;
}
}

View File

@@ -93,7 +93,7 @@ class Thermostat : public EMSdevice {
}
// determines if the heating circuit is actually present and has data
bool is_active() {
bool is_active() const {
return Helpers::hasValue(selTemp);
}
@@ -292,7 +292,7 @@ class Thermostat : public EMSdevice {
void register_device_values_hc(std::shared_ptr<Thermostat::HeatingCircuit> hc);
void add_ha_climate(std::shared_ptr<HeatingCircuit> hc);
void add_ha_climate(std::shared_ptr<HeatingCircuit> hc) const;
void process_RCOutdoorTemp(std::shared_ptr<const Telegram> telegram);
void process_IBASettings(std::shared_ptr<const Telegram> telegram);