mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
Merge branch 'dev' of https://github.com/emsesp/EMS-ESP32 into dev_no_master_thermostat
This commit is contained in:
@@ -293,7 +293,7 @@ std::shared_ptr<Thermostat::HeatingCircuit> Thermostat::heating_circuit(std::sha
|
||||
*/
|
||||
|
||||
// if it's the first set the status flag
|
||||
if (heating_circuits_.size() == 0) {
|
||||
if (heating_circuits_.empty()) {
|
||||
strlcpy(status_, "online", sizeof(status_));
|
||||
}
|
||||
|
||||
@@ -333,7 +333,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;
|
||||
@@ -452,65 +452,44 @@ std::string Thermostat::mode_tostring(uint8_t mode) {
|
||||
switch (mode) {
|
||||
case HeatingCircuit::Mode::OFF:
|
||||
return read_flash_string(F_(off));
|
||||
break;
|
||||
case HeatingCircuit::Mode::MANUAL:
|
||||
return read_flash_string(F_(manual));
|
||||
break;
|
||||
case HeatingCircuit::Mode::DAY:
|
||||
return read_flash_string(F_(day));
|
||||
break;
|
||||
case HeatingCircuit::Mode::NIGHT:
|
||||
return read_flash_string(F_(night));
|
||||
break;
|
||||
case HeatingCircuit::Mode::ECO:
|
||||
return read_flash_string(F_(eco));
|
||||
break;
|
||||
case HeatingCircuit::Mode::COMFORT:
|
||||
return read_flash_string(F_(comfort));
|
||||
break;
|
||||
case HeatingCircuit::Mode::HEAT:
|
||||
return read_flash_string(F_(heat));
|
||||
break;
|
||||
case HeatingCircuit::Mode::HOLIDAY:
|
||||
return read_flash_string(F_(holiday));
|
||||
break;
|
||||
case HeatingCircuit::Mode::NOFROST:
|
||||
return read_flash_string(F_(nofrost));
|
||||
break;
|
||||
case HeatingCircuit::Mode::AUTO:
|
||||
return read_flash_string(F_(auto));
|
||||
break;
|
||||
case HeatingCircuit::Mode::SUMMER:
|
||||
return read_flash_string(F_(summer));
|
||||
break;
|
||||
case HeatingCircuit::Mode::OFFSET:
|
||||
return read_flash_string(F_(offset));
|
||||
break;
|
||||
case HeatingCircuit::Mode::DESIGN:
|
||||
return read_flash_string(F_(design));
|
||||
break;
|
||||
case HeatingCircuit::Mode::MINFLOW:
|
||||
return read_flash_string(F_(minflow));
|
||||
break;
|
||||
case HeatingCircuit::Mode::MAXFLOW:
|
||||
return read_flash_string(F_(maxflow));
|
||||
break;
|
||||
case HeatingCircuit::Mode::ROOMINFLUENCE:
|
||||
return read_flash_string(F_(roominfluence[0]));
|
||||
break;
|
||||
case HeatingCircuit::Mode::FLOWOFFSET:
|
||||
return read_flash_string(F_(flowtempoffset[0]));
|
||||
break;
|
||||
case HeatingCircuit::Mode::TEMPAUTO:
|
||||
return read_flash_string(F_(tempauto));
|
||||
break;
|
||||
case HeatingCircuit::Mode::NOREDUCE:
|
||||
return read_flash_string(F_(noreduce));
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::UNKNOWN:
|
||||
return read_flash_string(F_(unknown));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1237,18 +1216,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_));
|
||||
@@ -1292,7 +1271,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) {
|
||||
@@ -1658,9 +1637,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;
|
||||
}
|
||||
@@ -1805,7 +1786,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;
|
||||
}
|
||||
|
||||
@@ -1907,9 +1888,7 @@ bool Thermostat::set_mode_n(const uint8_t mode, const uint8_t hc_num) {
|
||||
set_mode_value = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO:
|
||||
case HeatingCircuit::Mode::ECO:
|
||||
default: // AUTO & ECO
|
||||
set_mode_value = 2;
|
||||
break;
|
||||
}
|
||||
@@ -2133,7 +2112,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;
|
||||
@@ -2348,6 +2327,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) {
|
||||
@@ -2381,6 +2362,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) {
|
||||
@@ -2460,7 +2443,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
factor = 1;
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO:
|
||||
// HeatingCircuit::Mode::AUTO:
|
||||
uint8_t mode_ = hc->get_mode();
|
||||
if (mode_ == HeatingCircuit::Mode::MANUAL) {
|
||||
offset = 0x0A; // manual offset
|
||||
@@ -2499,7 +2482,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
offset = EMS_OFFSET_RC20_2_Set_temp_day;
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code
|
||||
// automatic selection, if no type is defined, we use the standard code
|
||||
uint8_t mode_ = hc->get_mode();
|
||||
if (mode_ == HeatingCircuit::Mode::NIGHT) {
|
||||
offset = EMS_OFFSET_RC20_2_Set_temp_night;
|
||||
@@ -2570,7 +2553,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
factor = 1;
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code
|
||||
// automatic selection, if no type is defined, we use the standard code
|
||||
validate_typeid = monitor_typeids[hc->hc()]; //get setpoint roomtemp back
|
||||
if (model == EMS_DEVICE_FLAG_RC35) {
|
||||
uint8_t mode_ = hc->get_mode();
|
||||
@@ -2606,7 +2589,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
offset = EMS_OFFSET_JunkersSetMessage_day_temp;
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code
|
||||
// automatic selection, if no type is defined, we use the standard code
|
||||
uint8_t modetype = hc->get_mode_type();
|
||||
if (modetype == HeatingCircuit::Mode::NIGHT || modetype == HeatingCircuit::Mode::ECO) {
|
||||
offset = EMS_OFFSET_JunkersSetMessage_night_temp;
|
||||
@@ -2633,7 +2616,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
offset = EMS_OFFSET_JunkersSetMessage2_heat_temp;
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code
|
||||
// automatic selection, if no type is defined, we use the standard code
|
||||
uint8_t modetype = hc->get_mode_type();
|
||||
if (modetype == HeatingCircuit::Mode::NIGHT || modetype == HeatingCircuit::Mode::ECO) {
|
||||
offset = EMS_OFFSET_JunkersSetMessage2_eco_temp;
|
||||
@@ -2651,7 +2634,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
if (offset != -1) {
|
||||
// add the write command to the Tx queue. value is *2
|
||||
// post validate is the corresponding monitor or set type IDs as they can differ per model
|
||||
write_command(set_typeid, offset, (uint8_t)((float)temperature * (float)factor), validate_typeid);
|
||||
write_command(set_typeid, offset, (uint8_t)(temperature * (float)factor), validate_typeid);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3300,6 +3283,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user