Skip to content

Commit

Permalink
Merge pull request #2157 from MichaelDvP/dev
Browse files Browse the repository at this point in the history
thermostat time #2142, boiler power reduction #2147
  • Loading branch information
proddy authored Oct 30, 2024
2 parents fcf8432 + 52adf67 commit 8bf97c0
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 24 deletions.
27 changes: 23 additions & 4 deletions src/devices/boiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,15 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const
FL_(pvMaxComp),
DeviceValueUOM::KW,
MAKE_CF_CB(set_pvMaxComp));
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
&powerReduction_,
DeviceValueType::UINT8,
DeviceValueNumOp::DV_NUMOP_MUL10,
FL_(powerReduction),
DeviceValueUOM::PERCENT,
MAKE_CF_CB(set_powerReduction),
30,
60);
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
&hpSetDiffPress_,
DeviceValueType::UINT8,
Expand Down Expand Up @@ -1937,10 +1946,11 @@ void Boiler::process_HpSilentMode(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, hpHystPool_, 33); // is / 5
has_update(telegram, hpCircPumpWw_, 46);
has_update(telegram, hpMaxPower_, 31);
has_update(telegram, silentFrom_, 52); // in steps of 15 min
has_update(telegram, silentTo_, 53); // in steps of 15 min
has_update(telegram, pvMaxComp_, 54); // #2062
has_update(telegram, hpshutdown_, 58); // 1 powers off
has_update(telegram, silentFrom_, 52); // in steps of 15 min
has_update(telegram, silentTo_, 53); // in steps of 15 min
has_update(telegram, pvMaxComp_, 54); // #2062
has_update(telegram, hpshutdown_, 58); // 1 powers off
has_update(telegram, powerReduction_, 64); // 3..6 -> is *10
}

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

bool Boiler::set_powerReduction(const char * value, const int8_t id) {
int v;
if (Helpers::value2number(value, v)) {
write_command(0x484, 64, v / 10, 0x484);
return true;
}
return false;
}

bool Boiler::set_vp_cooling(const char * value, const int8_t id) {
bool v;
if (Helpers::value2bool(value, v)) {
Expand Down
3 changes: 2 additions & 1 deletion src/devices/boiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class Boiler : public EMSdevice {
uint8_t maxHeatDhw_;
uint8_t hpMaxPower_;
uint8_t pvMaxComp_;
uint8_t powerReduction_;

uint8_t pvCooling_;
uint8_t manDefrost_;
Expand Down Expand Up @@ -332,7 +333,6 @@ class Boiler : public EMSdevice {
uint8_t delayBoiler_; // minutes
uint8_t tempDiffBoiler_; // relative temperature degrees
*/

void process_UBAFactory(std::shared_ptr<const Telegram> telegram);
void process_UBAParameterWW(std::shared_ptr<const Telegram> telegram);
void process_UBAMonitorFast(std::shared_ptr<const Telegram> telegram);
Expand Down Expand Up @@ -482,6 +482,7 @@ class Boiler : public EMSdevice {
bool set_pvMaxComp(const char * value, const int8_t id);
bool set_hpDiffPress(const char * value, const int8_t id);
bool set_hpPowerLimit(const char * value, const int8_t id);
bool set_powerReduction(const char * value, const int8_t id);

bool set_auxLimit(const char * value, const int8_t id);
inline bool set_auxMaxLimit(const char * value, const int8_t id) {
Expand Down
51 changes: 36 additions & 15 deletions src/devices/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,22 +1561,34 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
return; // not supported
}

static uint8_t setTimeRetry = 0;
uint8_t dst = 0xFE;
bool use_dst = !telegram->read_value(dst, 9) || dst == 0xFF;
if ((telegram->message_data[7] & 0x0C) && has_command(&dateTime_)) { // date and time not valid
set_datetime("ntp", -1); // set from NTP
if (setTimeRetry < 3) {
if (!use_dst) {
set_datetime("ntp", 0); // set from NTP without dst
} else {
set_datetime("ntp", -1); // set from NTP
}
setTimeRetry++;
}
return;
}

// check clock
time_t now = time(nullptr);
tm * tm_ = localtime(&now);
bool tset_ = tm_->tm_year > 110; // year 2010 and up, time is valid
tm_->tm_year = (telegram->message_data[0] & 0x7F) + 100; // IVT
tm_->tm_mon = telegram->message_data[1] - 1;
tm_->tm_mday = telegram->message_data[3];
tm_->tm_hour = telegram->message_data[2];
tm_->tm_min = telegram->message_data[4];
tm_->tm_sec = telegram->message_data[5];
tm_->tm_isdst = telegram->message_data[7] & 0x01;
time_t now = time(nullptr);
tm * tm_ = localtime(&now);
bool tset_ = tm_->tm_year > 110; // year 2010 and up, time is valid
tm_->tm_year = (telegram->message_data[0] & 0x7F) + 100; // IVT
tm_->tm_mon = telegram->message_data[1] - 1;
tm_->tm_mday = telegram->message_data[3];
tm_->tm_hour = telegram->message_data[2];
tm_->tm_min = telegram->message_data[4];
tm_->tm_sec = telegram->message_data[5];
if (use_dst) {
tm_->tm_isdst = telegram->message_data[7] & 0x01;
}

// render date to DD.MM.YYYY HH:MM and publish
char newdatetime[sizeof(dateTime_)];
Expand All @@ -1590,8 +1602,17 @@ 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_)) {
double difference = difftime(now, ttime);
if (difference > 15 || difference < -15) {
set_datetime("ntp", -1); // set from NTP
LOG_INFO("thermostat time correction from ntp");
if (setTimeRetry < 3) {
if (!use_dst) {
set_datetime("ntp", 0); // set from NTP without dst
} else {
set_datetime("ntp", -1); // set from NTP
}
LOG_INFO("thermostat time correction from ntp");
setTimeRetry++;
}
} else {
setTimeRetry = 0;
}
}
#ifndef EMSESP_STANDALONE
Expand Down Expand Up @@ -2685,8 +2706,8 @@ bool Thermostat::set_datetime(const char * value, const int8_t id) {
data[3] = tm_->tm_mday;
data[4] = tm_->tm_min;
data[5] = tm_->tm_sec;
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[6] = (tm_->tm_wday + 6) % 7; // Bosch counts from Mo, time from Su
data[7] = (id == 0) ? 2 : 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;
Expand Down
1 change: 1 addition & 0 deletions src/locale_translations.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ MAKE_TRANSLATION(gasMeterHeat, "gasmeterheat", "gas meter heating", "Gaszähler
MAKE_TRANSLATION(gasMeterWw, "gasmeter", "gas meter", "Gaszähler", "", "", "licznik gazu", "", "", "", "", "počítadlo plynu", "počítadlo plynu") // TODO translate
MAKE_TRANSLATION(hpCurrPower, "hpcurrpower", "compressor current power", "akt. Kompressorleistung", "", "", "", "", "", "", "", "", "aktuální výkon kompresoru") // TODO translate
MAKE_TRANSLATION(hpPowerLimit, "hppowerlimit", "power limit", "Leistungsgrenze", "", "", "", "", "", "", "", "", "omezení výkonu") // TODO translate
MAKE_TRANSLATION(powerReduction, "powerreduction", "power reduction", "Leistungsverringerung", "", "", "", "", "", "", "", "", "omezení výkonu") // TODO translate

// HIU
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
Expand Down
8 changes: 4 additions & 4 deletions src/roomcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,10 @@ void Roomctrl::check(uint8_t addr, const uint8_t * data, const uint8_t length) {
// empty message back if temperature not set or unknown message type
if (data[2] == EMSdevice::EMS_TYPE_VERSION) {
version(addr, data[0], hc);
} else if (length == 6) { // ems query
unknown(addr, data[0], data[2], data[3]);
} else if (length == 8) {
unknown(addr, data[0], data[3], data[5], data[6]);
} else if (data[2] == 0xAF && data[3] == 0) {
temperature(addr, data[0], hc);
} else if (length == 6) { // all other ems queries
unknown(addr, data[0], data[2], data[3]);
} else if (length == 8 && data[2] == 0xFF && data[3] == 0 && data[5] == 0 && data[6] == 0x23) { // Junkers
temperature(addr, data[0], hc);
} else if (length == 8 && data[2] == 0xFF && data[3] == 0 && data[5] == 3 && data[6] == 0x2B + hc) { // EMS+ temperature
Expand All @@ -182,6 +180,8 @@ void Roomctrl::check(uint8_t addr, const uint8_t * data, const uint8_t length) {
unknown(addr, data[0], data[3], data[5], data[6]);
} else if (data[2] == 0xF7) { // ems+ query with 3 bytes type src dst 7F offset len=FF FF HIGH LOW
replyF7(addr, data[0], data[3], data[5], data[6], data[7], hc);
} else if (length == 8) {
unknown(addr, data[0], data[3], data[5], data[6]);
}
}

Expand Down

0 comments on commit 8bf97c0

Please sign in to comment.