set thermostat datetetime: max 3 tries

This commit is contained in:
MichaelDvP
2024-10-27 15:16:12 +01:00
parent 65e0ae174a
commit b6053e9a7c

View File

@@ -1561,8 +1561,12 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
return; // not supported return; // not supported
} }
static uint8_t setTimeRetry = 0;
if ((telegram->message_data[7] & 0x0C) && has_command(&dateTime_)) { // date and time not valid if ((telegram->message_data[7] & 0x0C) && has_command(&dateTime_)) { // date and time not valid
if (setTimeRetry < 3) {
set_datetime("ntp", -1); // set from NTP set_datetime("ntp", -1); // set from NTP
setTimeRetry++;
}
return; return;
} }
@@ -1590,8 +1594,13 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
if (!ivtclock && !junkersclock && tset_ && EMSESP::system_.ntp_connected() && !EMSESP::system_.readonly_mode() && has_command(&dateTime_)) { if (!ivtclock && !junkersclock && tset_ && EMSESP::system_.ntp_connected() && !EMSESP::system_.readonly_mode() && has_command(&dateTime_)) {
double difference = difftime(now, ttime); double difference = difftime(now, ttime);
if (difference > 15 || difference < -15) { if (difference > 15 || difference < -15) {
if (setTimeRetry < 3) {
set_datetime("ntp", -1); // set from NTP set_datetime("ntp", -1); // set from NTP
LOG_INFO("thermostat time correction from ntp"); LOG_INFO("thermostat time correction from ntp");
setTimeRetry++;
}
} else {
setTimeRetry = 0;
} }
} }
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE