Skip to content

Commit 8bf97c0

Browse files
authored
Merge pull request #2157 from MichaelDvP/dev
thermostat time #2142, boiler power reduction #2147
2 parents fcf8432 + 52adf67 commit 8bf97c0

File tree

5 files changed

+66
-24
lines changed

5 files changed

+66
-24
lines changed

src/devices/boiler.cpp

+23-4
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,15 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const
555555
FL_(pvMaxComp),
556556
DeviceValueUOM::KW,
557557
MAKE_CF_CB(set_pvMaxComp));
558+
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
559+
&powerReduction_,
560+
DeviceValueType::UINT8,
561+
DeviceValueNumOp::DV_NUMOP_MUL10,
562+
FL_(powerReduction),
563+
DeviceValueUOM::PERCENT,
564+
MAKE_CF_CB(set_powerReduction),
565+
30,
566+
60);
558567
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
559568
&hpSetDiffPress_,
560569
DeviceValueType::UINT8,
@@ -1937,10 +1946,11 @@ void Boiler::process_HpSilentMode(std::shared_ptr<const Telegram> telegram) {
19371946
has_update(telegram, hpHystPool_, 33); // is / 5
19381947
has_update(telegram, hpCircPumpWw_, 46);
19391948
has_update(telegram, hpMaxPower_, 31);
1940-
has_update(telegram, silentFrom_, 52); // in steps of 15 min
1941-
has_update(telegram, silentTo_, 53); // in steps of 15 min
1942-
has_update(telegram, pvMaxComp_, 54); // #2062
1943-
has_update(telegram, hpshutdown_, 58); // 1 powers off
1949+
has_update(telegram, silentFrom_, 52); // in steps of 15 min
1950+
has_update(telegram, silentTo_, 53); // in steps of 15 min
1951+
has_update(telegram, pvMaxComp_, 54); // #2062
1952+
has_update(telegram, hpshutdown_, 58); // 1 powers off
1953+
has_update(telegram, powerReduction_, 64); // 3..6 -> is *10
19441954
}
19451955

19461956
// Boiler(0x08) -B-> All(0x00), ?(0x0488), data: 8E 00 00 00 00 00 01 03
@@ -3154,6 +3164,15 @@ bool Boiler::set_hpPowerLimit(const char * value, const int8_t id) {
31543164
return false;
31553165
}
31563166

3167+
bool Boiler::set_powerReduction(const char * value, const int8_t id) {
3168+
int v;
3169+
if (Helpers::value2number(value, v)) {
3170+
write_command(0x484, 64, v / 10, 0x484);
3171+
return true;
3172+
}
3173+
return false;
3174+
}
3175+
31573176
bool Boiler::set_vp_cooling(const char * value, const int8_t id) {
31583177
bool v;
31593178
if (Helpers::value2bool(value, v)) {

src/devices/boiler.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class Boiler : public EMSdevice {
256256
uint8_t maxHeatDhw_;
257257
uint8_t hpMaxPower_;
258258
uint8_t pvMaxComp_;
259+
uint8_t powerReduction_;
259260

260261
uint8_t pvCooling_;
261262
uint8_t manDefrost_;
@@ -332,7 +333,6 @@ class Boiler : public EMSdevice {
332333
uint8_t delayBoiler_; // minutes
333334
uint8_t tempDiffBoiler_; // relative temperature degrees
334335
*/
335-
336336
void process_UBAFactory(std::shared_ptr<const Telegram> telegram);
337337
void process_UBAParameterWW(std::shared_ptr<const Telegram> telegram);
338338
void process_UBAMonitorFast(std::shared_ptr<const Telegram> telegram);
@@ -482,6 +482,7 @@ class Boiler : public EMSdevice {
482482
bool set_pvMaxComp(const char * value, const int8_t id);
483483
bool set_hpDiffPress(const char * value, const int8_t id);
484484
bool set_hpPowerLimit(const char * value, const int8_t id);
485+
bool set_powerReduction(const char * value, const int8_t id);
485486

486487
bool set_auxLimit(const char * value, const int8_t id);
487488
inline bool set_auxMaxLimit(const char * value, const int8_t id) {

src/devices/thermostat.cpp

+36-15
Original file line numberDiff line numberDiff line change
@@ -1561,22 +1561,34 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
15611561
return; // not supported
15621562
}
15631563

1564+
static uint8_t setTimeRetry = 0;
1565+
uint8_t dst = 0xFE;
1566+
bool use_dst = !telegram->read_value(dst, 9) || dst == 0xFF;
15641567
if ((telegram->message_data[7] & 0x0C) && has_command(&dateTime_)) { // date and time not valid
1565-
set_datetime("ntp", -1); // set from NTP
1568+
if (setTimeRetry < 3) {
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+
}
1574+
setTimeRetry++;
1575+
}
15661576
return;
15671577
}
15681578

15691579
// check clock
1570-
time_t now = time(nullptr);
1571-
tm * tm_ = localtime(&now);
1572-
bool tset_ = tm_->tm_year > 110; // year 2010 and up, time is valid
1573-
tm_->tm_year = (telegram->message_data[0] & 0x7F) + 100; // IVT
1574-
tm_->tm_mon = telegram->message_data[1] - 1;
1575-
tm_->tm_mday = telegram->message_data[3];
1576-
tm_->tm_hour = telegram->message_data[2];
1577-
tm_->tm_min = telegram->message_data[4];
1578-
tm_->tm_sec = telegram->message_data[5];
1579-
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+
}
15801592

15811593
// render date to DD.MM.YYYY HH:MM and publish
15821594
char newdatetime[sizeof(dateTime_)];
@@ -1590,8 +1602,17 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
15901602
if (!ivtclock && !junkersclock && tset_ && EMSESP::system_.ntp_connected() && !EMSESP::system_.readonly_mode() && has_command(&dateTime_)) {
15911603
double difference = difftime(now, ttime);
15921604
if (difference > 15 || difference < -15) {
1593-
set_datetime("ntp", -1); // set from NTP
1594-
LOG_INFO("thermostat time correction from ntp");
1605+
if (setTimeRetry < 3) {
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+
}
1611+
LOG_INFO("thermostat time correction from ntp");
1612+
setTimeRetry++;
1613+
}
1614+
} else {
1615+
setTimeRetry = 0;
15951616
}
15961617
}
15971618
#ifndef EMSESP_STANDALONE
@@ -2685,8 +2706,8 @@ bool Thermostat::set_datetime(const char * value, const int8_t id) {
26852706
data[3] = tm_->tm_mday;
26862707
data[4] = tm_->tm_min;
26872708
data[5] = tm_->tm_sec;
2688-
data[6] = (tm_->tm_wday + 6) % 7; // Bosch counts from Mo, time from Su
2689-
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
26902711
if (model() == EMSdevice::EMS_DEVICE_FLAG_JUNKERS) {
26912712
data[6]++; // Junkers use 1-7;
26922713
data[7] = 0;

src/locale_translations.h

+1
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ MAKE_TRANSLATION(gasMeterHeat, "gasmeterheat", "gas meter heating", "Gaszähler
576576
MAKE_TRANSLATION(gasMeterWw, "gasmeter", "gas meter", "Gaszähler", "", "", "licznik gazu", "", "", "", "", "počítadlo plynu", "počítadlo plynu") // TODO translate
577577
MAKE_TRANSLATION(hpCurrPower, "hpcurrpower", "compressor current power", "akt. Kompressorleistung", "", "", "", "", "", "", "", "", "aktuální výkon kompresoru") // TODO translate
578578
MAKE_TRANSLATION(hpPowerLimit, "hppowerlimit", "power limit", "Leistungsgrenze", "", "", "", "", "", "", "", "", "omezení výkonu") // TODO translate
579+
MAKE_TRANSLATION(powerReduction, "powerreduction", "power reduction", "Leistungsverringerung", "", "", "", "", "", "", "", "", "omezení výkonu") // TODO translate
579580

580581
// HIU
581582
MAKE_TRANSLATION(netFlowTemp, "netflowtemp", "heat network flow temp", "Systemvorlauftemperatur", "Netto aanvoertemperatuur", "", "temp. zasilania sieci cieplnej", "", "", "ısıtma şebekesi akış derecesi", "temperatura di mandata della rete di riscaldamento", "teplota prívodu tepelnej siete", "teplota přívodu tepelné sítě") // TODO translate

src/roomcontrol.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,10 @@ void Roomctrl::check(uint8_t addr, const uint8_t * data, const uint8_t length) {
166166
// empty message back if temperature not set or unknown message type
167167
if (data[2] == EMSdevice::EMS_TYPE_VERSION) {
168168
version(addr, data[0], hc);
169-
} else if (length == 6) { // ems query
170-
unknown(addr, data[0], data[2], data[3]);
171-
} else if (length == 8) {
172-
unknown(addr, data[0], data[3], data[5], data[6]);
173169
} else if (data[2] == 0xAF && data[3] == 0) {
174170
temperature(addr, data[0], hc);
171+
} else if (length == 6) { // all other ems queries
172+
unknown(addr, data[0], data[2], data[3]);
175173
} else if (length == 8 && data[2] == 0xFF && data[3] == 0 && data[5] == 0 && data[6] == 0x23) { // Junkers
176174
temperature(addr, data[0], hc);
177175
} else if (length == 8 && data[2] == 0xFF && data[3] == 0 && data[5] == 3 && data[6] == 0x2B + hc) { // EMS+ temperature
@@ -182,6 +180,8 @@ void Roomctrl::check(uint8_t addr, const uint8_t * data, const uint8_t length) {
182180
unknown(addr, data[0], data[3], data[5], data[6]);
183181
} else if (data[2] == 0xF7) { // ems+ query with 3 bytes type src dst 7F offset len=FF FF HIGH LOW
184182
replyF7(addr, data[0], data[3], data[5], data[6], data[7], hc);
183+
} else if (length == 8) {
184+
unknown(addr, data[0], data[3], data[5], data[6]);
185185
}
186186
}
187187

0 commit comments

Comments
 (0)