ivt clock check dst

This commit is contained in:
MichaelDvP
2022-04-04 11:11:37 +02:00
parent 917e4f5cbf
commit 26758b965d

View File

@@ -1244,7 +1244,7 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
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
bool ivtclock = (telegram->message_data[0] & 0x80) == 0x80; // dont set clock on ivt, #439 bool ivtclock = (telegram->message_data[0] & 0x80) == 0x80; // dont sync ivt-clock, #439
// correct thermostat clock if we have valid ntp time, and could write the command // correct thermostat clock if we have valid ntp time, and could write the command
if (!ivtclock && tset_ && EMSESP::system_.ntp_connected() && !EMSESP::system_.readonly_mode() && has_command(&dateTime_)) { if (!ivtclock && tset_ && EMSESP::system_.ntp_connected() && !EMSESP::system_.readonly_mode() && has_command(&dateTime_)) {
double difference = difftime(now, ttime); double difference = difftime(now, ttime);
@@ -1255,6 +1255,10 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
} }
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
if (!tset_ && tm_->tm_year > 110) { // emsesp clock not set, but thermostat clock if (!tset_ && tm_->tm_year > 110) { // emsesp clock not set, but thermostat clock
if (ivtclock) {
tm_->tm_isdst = -1; // determine dst
ttime = mktime(tm_); // thermostat time
}
struct timeval newnow = {.tv_sec = ttime}; struct timeval newnow = {.tv_sec = ttime};
settimeofday(&newnow, nullptr); settimeofday(&newnow, nullptr);
LOG_INFO(F("ems-esp time set from thermostat")); LOG_INFO(F("ems-esp time set from thermostat"));