mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Merge pull request #432 from MichaelDvP/dev
fix/optimization for mode/temperature set
This commit is contained in:
@@ -1243,8 +1243,8 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
|
|||||||
tm_->tm_min = telegram->message_data[4];
|
tm_->tm_min = telegram->message_data[4];
|
||||||
tm_->tm_sec = telegram->message_data[5];
|
tm_->tm_sec = telegram->message_data[5];
|
||||||
tm_->tm_isdst = telegram->message_data[7] & 0x01;
|
tm_->tm_isdst = telegram->message_data[7] & 0x01;
|
||||||
time_t ttime = mktime(tm_); // thermostat time
|
time_t ttime = mktime(tm_); // thermostat time
|
||||||
if (tset_ && EMSESP::system_.ntp_connected() && has_command(&dateTime_)) { // have NTP time and command
|
if (tset_ && EMSESP::system_.ntp_connected() && has_command(&dateTime_)) { // have NTP time and command
|
||||||
double difference = difftime(now, ttime);
|
double difference = difftime(now, ttime);
|
||||||
if (difference > 15 || difference < -15) {
|
if (difference > 15 || difference < -15) {
|
||||||
set_datetime("ntp", -1); // set from NTP
|
set_datetime("ntp", -1); // set from NTP
|
||||||
@@ -1968,7 +1968,8 @@ bool Thermostat::set_mode_n(const uint8_t mode, const uint8_t hc_num) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (model()) {
|
uint8_t model_ = model();
|
||||||
|
switch (model_) {
|
||||||
case EMSdevice::EMS_DEVICE_FLAG_RC10:
|
case EMSdevice::EMS_DEVICE_FLAG_RC10:
|
||||||
offset = 0;
|
offset = 0;
|
||||||
validate_typeid = 0xB1;
|
validate_typeid = 0xB1;
|
||||||
@@ -2032,8 +2033,12 @@ bool Thermostat::set_mode_n(const uint8_t mode, const uint8_t hc_num) {
|
|||||||
write_command(set_typeid, offset, set_mode_value, validate_typeid);
|
write_command(set_typeid, offset, set_mode_value, validate_typeid);
|
||||||
|
|
||||||
// set hc->mode temporary until validate is received
|
// set hc->mode temporary until validate is received
|
||||||
if (model() == EMSdevice::EMS_DEVICE_FLAG_RC10) {
|
if (model_ == EMSdevice::EMS_DEVICE_FLAG_RC10) {
|
||||||
hc->mode = set_mode_value >> 1;
|
hc->mode = set_mode_value >> 1;
|
||||||
|
} else if (model_ == EMSdevice::EMS_DEVICE_FLAG_RC300 || model_ == EMSdevice::EMS_DEVICE_FLAG_RC100) {
|
||||||
|
hc->mode = set_mode_value ? 1 : 0;
|
||||||
|
} else if (model_ == EMSdevice::EMS_DEVICE_FLAG_JUNKERS) {
|
||||||
|
hc->mode = set_mode_value - 1;
|
||||||
} else {
|
} else {
|
||||||
hc->mode = set_mode_value;
|
hc->mode = set_mode_value;
|
||||||
}
|
}
|
||||||
@@ -2680,16 +2685,15 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
|||||||
default:
|
default:
|
||||||
// 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
|
validate_typeid = monitor_typeids[hc->hc()]; //get setpoint roomtemp back
|
||||||
if (model == EMS_DEVICE_FLAG_RC35) {
|
uint8_t mode_ = hc->get_mode();
|
||||||
uint8_t mode_ = hc->get_mode();
|
if (mode_ == HeatingCircuit::Mode::NIGHT) {
|
||||||
if (mode_ == HeatingCircuit::Mode::NIGHT) {
|
offset = EMS_OFFSET_RC35Set_temp_night;
|
||||||
offset = EMS_OFFSET_RC35Set_temp_night;
|
} else if (mode_ == HeatingCircuit::Mode::DAY) {
|
||||||
} else if (mode_ == HeatingCircuit::Mode::DAY) {
|
offset = EMS_OFFSET_RC35Set_temp_day;
|
||||||
offset = EMS_OFFSET_RC35Set_temp_day;
|
} else if (model == EMS_DEVICE_FLAG_RC35) {
|
||||||
} else {
|
offset = EMS_OFFSET_RC35Set_seltemp; // https://github.com/emsesp/EMS-ESP/issues/310
|
||||||
offset = EMS_OFFSET_RC35Set_seltemp; // https://github.com/emsesp/EMS-ESP/issues/310
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
// RC30_N missing temporary auto temperature https://github.com/emsesp/EMS-ESP32/issues/395
|
||||||
uint8_t modetype = hc->get_mode_type();
|
uint8_t modetype = hc->get_mode_type();
|
||||||
offset = (modetype == HeatingCircuit::Mode::NIGHT) ? EMS_OFFSET_RC35Set_temp_night : EMS_OFFSET_RC35Set_temp_day;
|
offset = (modetype == HeatingCircuit::Mode::NIGHT) ? EMS_OFFSET_RC35Set_temp_night : EMS_OFFSET_RC35Set_temp_day;
|
||||||
}
|
}
|
||||||
@@ -2714,14 +2718,24 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
|||||||
offset = EMS_OFFSET_JunkersSetMessage_day_temp;
|
offset = EMS_OFFSET_JunkersSetMessage_day_temp;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// automatic selection, if no type is defined, we use the standard code
|
// automatic selection, if no type is defined, we check mode and modetype
|
||||||
uint8_t modetype = hc->get_mode_type();
|
uint8_t mode_ = hc->get_mode();
|
||||||
if (modetype == HeatingCircuit::Mode::NIGHT || modetype == HeatingCircuit::Mode::ECO) {
|
if (mode_ == HeatingCircuit::Mode::NIGHT || mode_ == HeatingCircuit::Mode::ECO) {
|
||||||
offset = EMS_OFFSET_JunkersSetMessage_night_temp;
|
offset = EMS_OFFSET_JunkersSetMessage_night_temp;
|
||||||
} else if (modetype == HeatingCircuit::Mode::DAY || modetype == HeatingCircuit::Mode::HEAT) {
|
} else if (mode_ == HeatingCircuit::Mode::DAY || mode_ == HeatingCircuit::Mode::HEAT) {
|
||||||
offset = EMS_OFFSET_JunkersSetMessage_day_temp;
|
offset = EMS_OFFSET_JunkersSetMessage_day_temp;
|
||||||
} else {
|
} else if (mode_ == HeatingCircuit::Mode::NOFROST) {
|
||||||
offset = EMS_OFFSET_JunkersSetMessage_no_frost_temp;
|
offset = EMS_OFFSET_JunkersSetMessage_no_frost_temp;
|
||||||
|
} else {
|
||||||
|
// auto mode, missing temporary parameter, use modetype https://github.com/emsesp/EMS-ESP32/issues/400
|
||||||
|
uint8_t modetype = hc->get_mode_type();
|
||||||
|
if (modetype == HeatingCircuit::Mode::NIGHT || modetype == HeatingCircuit::Mode::ECO) {
|
||||||
|
offset = EMS_OFFSET_JunkersSetMessage_night_temp;
|
||||||
|
} else if (modetype == HeatingCircuit::Mode::DAY || modetype == HeatingCircuit::Mode::HEAT) {
|
||||||
|
offset = EMS_OFFSET_JunkersSetMessage_day_temp;
|
||||||
|
} else {
|
||||||
|
offset = EMS_OFFSET_JunkersSetMessage_no_frost_temp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2741,14 +2755,24 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
|||||||
offset = EMS_OFFSET_JunkersSetMessage2_heat_temp;
|
offset = EMS_OFFSET_JunkersSetMessage2_heat_temp;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// automatic selection, if no type is defined, we use the standard code
|
// automatic selection, if no type is defined, we check mode and modetype
|
||||||
uint8_t modetype = hc->get_mode_type();
|
uint8_t mode_ = hc->get_mode();
|
||||||
if (modetype == HeatingCircuit::Mode::NIGHT || modetype == HeatingCircuit::Mode::ECO) {
|
if (mode_ == HeatingCircuit::Mode::NIGHT || mode_ == HeatingCircuit::Mode::ECO) {
|
||||||
offset = EMS_OFFSET_JunkersSetMessage2_eco_temp;
|
offset = EMS_OFFSET_JunkersSetMessage2_eco_temp;
|
||||||
} else if (modetype == HeatingCircuit::Mode::DAY || modetype == HeatingCircuit::Mode::HEAT) {
|
} else if (mode_ == HeatingCircuit::Mode::DAY || mode_ == HeatingCircuit::Mode::HEAT) {
|
||||||
offset = EMS_OFFSET_JunkersSetMessage2_heat_temp;
|
offset = EMS_OFFSET_JunkersSetMessage2_heat_temp;
|
||||||
} else {
|
} else if (mode_ == HeatingCircuit::Mode::NOFROST) {
|
||||||
offset = EMS_OFFSET_JunkersSetMessage2_no_frost_temp;
|
offset = EMS_OFFSET_JunkersSetMessage2_no_frost_temp;
|
||||||
|
} else {
|
||||||
|
// auto mode, missing temporary parameter, use modetype https://github.com/emsesp/EMS-ESP32/issues/400
|
||||||
|
uint8_t modetype = hc->get_mode_type();
|
||||||
|
if (modetype == HeatingCircuit::Mode::NIGHT || modetype == HeatingCircuit::Mode::ECO) {
|
||||||
|
offset = EMS_OFFSET_JunkersSetMessage2_eco_temp;
|
||||||
|
} else if (modetype == HeatingCircuit::Mode::DAY || modetype == HeatingCircuit::Mode::HEAT) {
|
||||||
|
offset = EMS_OFFSET_JunkersSetMessage2_heat_temp;
|
||||||
|
} else {
|
||||||
|
offset = EMS_OFFSET_JunkersSetMessage2_no_frost_temp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user