mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 08:49:52 +03:00
set thermostat datetetime: max 3 tries
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user