mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Junkers settime, dst always zero, no check against NTP
This commit is contained in:
@@ -1364,10 +1364,11 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
|
|||||||
strftime(newdatetime, sizeof(dateTime_), "%d.%m.%G %H:%M", tm_);
|
strftime(newdatetime, sizeof(dateTime_), "%d.%m.%G %H:%M", tm_);
|
||||||
has_update(dateTime_, newdatetime, sizeof(dateTime_));
|
has_update(dateTime_, newdatetime, sizeof(dateTime_));
|
||||||
|
|
||||||
bool ivtclock = (telegram->message_data[0] & 0x80) == 0x80; // dont sync ivt-clock, #439
|
bool ivtclock = (telegram->message_data[0] & 0x80) == 0x80; // dont sync ivt-clock, #439
|
||||||
time_t ttime = mktime(tm_); // thermostat time
|
bool junkersclock = model() == EMSdevice::EMS_DEVICE_FLAG_JUNKERS;
|
||||||
|
time_t ttime = mktime(tm_); // thermostat time
|
||||||
// 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 && !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) {
|
||||||
set_datetime("ntp", -1); // set from NTP
|
set_datetime("ntp", -1); // set from NTP
|
||||||
@@ -2165,6 +2166,10 @@ bool Thermostat::set_datetime(const char * value, const int8_t id) {
|
|||||||
data[5] = tm_->tm_sec;
|
data[5] = tm_->tm_sec;
|
||||||
data[6] = (tm_->tm_wday + 6) % 7; // Bosch counts from Mo, time from Su
|
data[6] = (tm_->tm_wday + 6) % 7; // Bosch counts from Mo, time from Su
|
||||||
data[7] = tm_->tm_isdst + 2; // set DST and flag for ext. clock
|
data[7] = tm_->tm_isdst + 2; // set DST and flag for ext. clock
|
||||||
|
if (model() == EMSdevice::EMS_DEVICE_FLAG_JUNKERS) {
|
||||||
|
data[6]++; // Junkers use 1-7;
|
||||||
|
data[7] = 0;
|
||||||
|
}
|
||||||
} else if (dt.length() == 23) {
|
} else if (dt.length() == 23) {
|
||||||
data[0] = (dt[7] - '0') * 100 + (dt[8] - '0') * 10 + (dt[9] - '0'); // year
|
data[0] = (dt[7] - '0') * 100 + (dt[8] - '0') * 10 + (dt[9] - '0'); // year
|
||||||
data[1] = (dt[3] - '0') * 10 + (dt[4] - '0'); // month
|
data[1] = (dt[3] - '0') * 10 + (dt[4] - '0'); // month
|
||||||
@@ -2174,6 +2179,9 @@ bool Thermostat::set_datetime(const char * value, const int8_t id) {
|
|||||||
data[5] = (dt[17] - '0') * 10 + (dt[18] - '0'); // sec
|
data[5] = (dt[17] - '0') * 10 + (dt[18] - '0'); // sec
|
||||||
data[6] = (dt[20] - '0'); // day of week, Mo:0
|
data[6] = (dt[20] - '0'); // day of week, Mo:0
|
||||||
data[7] = (dt[22] - '0') + 2; // DST and flag
|
data[7] = (dt[22] - '0') + 2; // DST and flag
|
||||||
|
if (model() == EMSdevice::EMS_DEVICE_FLAG_JUNKERS) {
|
||||||
|
data[7] = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_WARNING(F("Set date: invalid data, wrong length"));
|
LOG_WARNING(F("Set date: invalid data, wrong length"));
|
||||||
return false;
|
return false;
|
||||||
@@ -3847,8 +3855,18 @@ void Thermostat::register_device_values() {
|
|||||||
break;
|
break;
|
||||||
case EMS_DEVICE_FLAG_JUNKERS:
|
case EMS_DEVICE_FLAG_JUNKERS:
|
||||||
// FR100 is not writable, see. https://github.com/emsesp/EMS-ESP32/issues/536
|
// FR100 is not writable, see. https://github.com/emsesp/EMS-ESP32/issues/536
|
||||||
// also FW500 https://github.com/emsesp/EMS-ESP32/issues/666
|
// FW500 is not writable, see. https://github.com/emsesp/EMS-ESP32/issues/666
|
||||||
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &dateTime_, DeviceValueType::STRING, FL_(tpl_datetime), FL_(dateTime), DeviceValueUOM::NONE);
|
if (has_flags(EMS_DEVICE_FLAG_JUNKERS_OLD)) {
|
||||||
|
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &dateTime_, DeviceValueType::STRING, FL_(tpl_datetime), FL_(dateTime), DeviceValueUOM::NONE);
|
||||||
|
} else {
|
||||||
|
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
|
||||||
|
&dateTime_,
|
||||||
|
DeviceValueType::STRING,
|
||||||
|
FL_(tpl_datetime),
|
||||||
|
FL_(dateTime),
|
||||||
|
DeviceValueUOM::NONE,
|
||||||
|
MAKE_CF_CB(set_datetime));
|
||||||
|
}
|
||||||
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
|
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
|
||||||
&hybridStrategy_,
|
&hybridStrategy_,
|
||||||
DeviceValueType::ENUM,
|
DeviceValueType::ENUM,
|
||||||
|
|||||||
Reference in New Issue
Block a user