@@ -1562,25 +1562,33 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
1562
1562
}
1563
1563
1564
1564
static uint8_t setTimeRetry = 0 ;
1565
+ uint8_t dst = 0xFE ;
1566
+ bool use_dst = !telegram->read_value (dst, 9 ) || dst == 0xFF ;
1565
1567
if ((telegram->message_data [7 ] & 0x0C ) && has_command (&dateTime_)) { // date and time not valid
1566
1568
if (setTimeRetry < 3 ) {
1567
- set_datetime (" ntp" , -1 ); // set from NTP
1569
+ if (!use_dst) {
1570
+ set_datetime (" ntp" , 0 ); // set from NTP without dst
1571
+ } else {
1572
+ set_datetime (" ntp" , -1 ); // set from NTP
1573
+ }
1568
1574
setTimeRetry++;
1569
1575
}
1570
1576
return ;
1571
1577
}
1572
1578
1573
1579
// check clock
1574
- time_t now = time (nullptr );
1575
- tm * tm_ = localtime (&now);
1576
- bool tset_ = tm_->tm_year > 110 ; // year 2010 and up, time is valid
1577
- tm_->tm_year = (telegram->message_data [0 ] & 0x7F ) + 100 ; // IVT
1578
- tm_->tm_mon = telegram->message_data [1 ] - 1 ;
1579
- tm_->tm_mday = telegram->message_data [3 ];
1580
- tm_->tm_hour = telegram->message_data [2 ];
1581
- tm_->tm_min = telegram->message_data [4 ];
1582
- tm_->tm_sec = telegram->message_data [5 ];
1583
- tm_->tm_isdst = telegram->message_data [7 ] & 0x01 ;
1580
+ time_t now = time (nullptr );
1581
+ tm * tm_ = localtime (&now);
1582
+ bool tset_ = tm_->tm_year > 110 ; // year 2010 and up, time is valid
1583
+ tm_->tm_year = (telegram->message_data [0 ] & 0x7F ) + 100 ; // IVT
1584
+ tm_->tm_mon = telegram->message_data [1 ] - 1 ;
1585
+ tm_->tm_mday = telegram->message_data [3 ];
1586
+ tm_->tm_hour = telegram->message_data [2 ];
1587
+ tm_->tm_min = telegram->message_data [4 ];
1588
+ tm_->tm_sec = telegram->message_data [5 ];
1589
+ if (use_dst) {
1590
+ tm_->tm_isdst = telegram->message_data [7 ] & 0x01 ;
1591
+ }
1584
1592
1585
1593
// render date to DD.MM.YYYY HH:MM and publish
1586
1594
char newdatetime[sizeof (dateTime_)];
@@ -1595,7 +1603,11 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
1595
1603
double difference = difftime (now, ttime);
1596
1604
if (difference > 15 || difference < -15 ) {
1597
1605
if (setTimeRetry < 3 ) {
1598
- set_datetime (" ntp" , -1 ); // set from NTP
1606
+ if (!use_dst) {
1607
+ set_datetime (" ntp" , 0 ); // set from NTP without dst
1608
+ } else {
1609
+ set_datetime (" ntp" , -1 ); // set from NTP
1610
+ }
1599
1611
LOG_INFO (" thermostat time correction from ntp" );
1600
1612
setTimeRetry++;
1601
1613
}
@@ -2694,8 +2706,8 @@ bool Thermostat::set_datetime(const char * value, const int8_t id) {
2694
2706
data[3 ] = tm_->tm_mday ;
2695
2707
data[4 ] = tm_->tm_min ;
2696
2708
data[5 ] = tm_->tm_sec ;
2697
- data[6 ] = (tm_->tm_wday + 6 ) % 7 ; // Bosch counts from Mo, time from Su
2698
- data[7 ] = tm_->tm_isdst + 2 ; // set DST and flag for ext. clock
2709
+ data[6 ] = (tm_->tm_wday + 6 ) % 7 ; // Bosch counts from Mo, time from Su
2710
+ data[7 ] = (id == 0 ) ? 2 : tm_->tm_isdst + 2 ; // set DST and flag for ext. clock
2699
2711
if (model () == EMSdevice::EMS_DEVICE_FLAG_JUNKERS) {
2700
2712
data[6 ]++; // Junkers use 1-7;
2701
2713
data[7 ] = 0 ;
0 commit comments