Skip to content

Commit

Permalink
Merge pull request emsesp#2305 from MichaelDvP/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy authored Dec 23, 2024
2 parents 0b4f174 + 4c69c9e commit ba3ae5e
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
2 changes: 1 addition & 1 deletion interface/src/app/status/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const SystemStatus = () => {
case NTPSyncStatus.NTP_INACTIVE:
return LL.INACTIVE(0);
case NTPSyncStatus.NTP_ACTIVE:
return LL.ACTIVE() + ' (' + formatDateTime(data.ntp_time ?? '') + ')';
return LL.ACTIVE() + (data.ntp_time !== undefined) ? ' (' + formatDateTime(data.ntp_time) + ')' : '';
default:
return LL.UNKNOWN();
}
Expand Down
2 changes: 1 addition & 1 deletion src/device_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

// Thermostat - Buderus/Nefit/Bosch specific - 0x17 / 0x10 / 0x18 / 0x19-0x1B for hc2-4 / 0x38
{ 4, DeviceType::THERMOSTAT, "UI800, BC400", DeviceFlags::EMS_DEVICE_FLAG_BC400}, // 0x10
{ 10, DeviceType::THERMOSTAT, "CR11", DeviceFlags::EMS_DEVICE_FLAG_RC100}, // 0x18
{ 10, DeviceType::THERMOSTAT, "CR11", DeviceFlags::EMS_DEVICE_FLAG_CR11}, // 0x18
{ 65, DeviceType::THERMOSTAT, "RC10", DeviceFlags::EMS_DEVICE_FLAG_RC20_N},// 0x17
{ 67, DeviceType::THERMOSTAT, "RC30", DeviceFlags::EMS_DEVICE_FLAG_RC30_N},// 0x10 - based on RC35
{ 77, DeviceType::THERMOSTAT, "RC20, Moduline 300", DeviceFlags::EMS_DEVICE_FLAG_RC20},// 0x17
Expand Down
45 changes: 40 additions & 5 deletions src/devices/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i
register_telegram_type(monitor_typeids[i], "CRFMonitor", false, MAKE_PF_CB(process_CRFMonitor));
}

} else if (model == EMSdevice::EMS_DEVICE_FLAG_CR11) {
monitor_typeids = {0x02A5};
set_typeids = {0x2B9};
curve_typeids = {0x029B};
register_telegram_type(monitor_typeids[0], "RC300Monitor", true, MAKE_PF_CB(process_CR11Monitor));
register_telegram_type(set_typeids[0], "RC300Set", false, MAKE_PF_CB(process_RC300Set));
register_telegram_type(curve_typeids[0], "RC300Curves", true, MAKE_PF_CB(process_RC300Curve));

// RC300/RC100 variants
} else if (isRC300() || (model == EMSdevice::EMS_DEVICE_FLAG_RC100)) {
monitor_typeids = {0x02A5, 0x02A6, 0x02A7, 0x02A8, 0x02A9, 0x02AA, 0x02AB, 0x02AC};
Expand Down Expand Up @@ -491,6 +499,8 @@ uint8_t Thermostat::HeatingCircuit::get_mode() const {
} else if (mode == 1) {
return HeatingCircuit::Mode::OFF;
}
} else if (model == EMSdevice::EMS_DEVICE_FLAG_CR11) {
return HeatingCircuit::Mode::MANUAL;
} else if (model == EMSdevice::EMS_DEVICE_FLAG_BC400 || model == EMSdevice::EMS_DEVICE_FLAG_CR120) {
if (mode_new == 0) {
return HeatingCircuit::Mode::OFF;
Expand Down Expand Up @@ -1053,6 +1063,21 @@ void Thermostat::process_CRFMonitor(std::shared_ptr<const Telegram> telegram) {
add_ha_climate(hc);
}

// type 0x02A5 - data from CR11
void Thermostat::process_CR11Monitor(std::shared_ptr<const Telegram> telegram) {
auto hc = heating_circuit(telegram);
if (hc == nullptr) {
return;
}

has_update(telegram, hc->roomTemp, 0); // is * 10
has_update(hc->mode, 0); // set manual for CR11
has_update(telegram, hc->selTemp, 6, 1); // is * 2, force as single byte
has_update(telegram, hc->targetflowtemp, 4);

add_ha_climate(hc);
}

// type 0x02A5 - data from the Nefit RC1010/3000 thermostat (0x18) and RC300/310s on 0x10
// Rx: 10 0B FF 00 01 A5 80 00 01 30 23 00 30 28 01 E7 03 03 01 01 E7 02 33 00 00 11 01 03 FF FF 00 04
void Thermostat::process_RC300Monitor(std::shared_ptr<const Telegram> telegram) {
Expand Down Expand Up @@ -1096,7 +1121,7 @@ void Thermostat::process_RC300Monitor(std::shared_ptr<const Telegram> telegram)
// Thermostat(0x10) -> Me(0x0B), RC300Set(0x2B9), data: FF 2E 2A 26 1E 02 4E FF FF 00 1C 01 E1 20 01 0F 05 00 00 02 1F
void Thermostat::process_RC300Set(std::shared_ptr<const Telegram> telegram) {
auto hc = heating_circuit(telegram);
if (hc == nullptr) {
if (hc == nullptr || model() == EMSdevice::EMS_DEVICE_FLAG_CR11) {
return;
}

Expand All @@ -1112,9 +1137,6 @@ void Thermostat::process_RC300Set(std::shared_ptr<const Telegram> telegram) {
// set mode for CR120, BC400, https://github.com/emsesp/EMS-ESP32/discussions/1779
has_update(telegram, hc->mode_new, 21); // for BC400, CR120
has_bitupdate(telegram, hc->mode, 0, 0); // RC300, RC100
if (hc->mode == EMS_VALUE_UINT8_NOTSET) {
has_update(hc->mode, 0); // set manual for CR11
}
has_update(telegram, hc->daytemp, 2); // is * 2
has_update(telegram, hc->nighttemp, 4); // is * 2

Expand Down Expand Up @@ -3726,6 +3748,9 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
break;
}

} else if (model == EMSdevice::EMS_DEVICE_FLAG_CR11) {
offset = 10; // just seltemp write to manualtemp

} else if (isRC300() || (model == EMSdevice::EMS_DEVICE_FLAG_RC100)) {
validate_typeid = set_typeids[hc->hc()];
switch (mode) {
Expand Down Expand Up @@ -4485,6 +4510,8 @@ void Thermostat::register_device_values() {
// Easy TC100 have no date/time, see issue #100, not sure about CT200, so leave it.
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &dateTime_, DeviceValueType::STRING, FL_(dateTime), DeviceValueUOM::NONE); // can't set datetime
break;
case EMSdevice::EMS_DEVICE_FLAG_CR11:
break;
case EMSdevice::EMS_DEVICE_FLAG_CRF:
default:
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &dateTime_, DeviceValueType::STRING, FL_(dateTime), DeviceValueUOM::NONE); // can't set datetime
Expand Down Expand Up @@ -4680,13 +4707,21 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
DeviceValueNumOp::DV_NUMOP_DIV2,
FL_(redthreshold),
DeviceValueUOM::DEGREES,
MAKE_CF_CB(set_redthreshold));
MAKE_CF_CB(set_redthreshold),
12,
22);
break;
case EMSdevice::EMS_DEVICE_FLAG_CRF:
register_device_value(tag, &hc->mode, DeviceValueType::ENUM, FL_(enum_mode5), FL_(mode), DeviceValueUOM::NONE);
register_device_value(tag, &hc->modetype, DeviceValueType::ENUM, FL_(enum_modetype5), FL_(modetype), DeviceValueUOM::NONE);
register_device_value(tag, &hc->targetflowtemp, DeviceValueType::UINT8, FL_(targetflowtemp), DeviceValueUOM::DEGREES);
break;
case EMSdevice::EMS_DEVICE_FLAG_CR11:
register_device_value(tag, &hc->mode, DeviceValueType::ENUM, FL_(enum_mode), FL_(mode), DeviceValueUOM::NONE);
register_device_value(tag, &hc->targetflowtemp, DeviceValueType::UINT8, FL_(targetflowtemp), DeviceValueUOM::DEGREES);
register_device_value(
tag, &hc->heatingtype, DeviceValueType::ENUM, FL_(enum_heatingtype), FL_(heatingtype), DeviceValueUOM::NONE, MAKE_CF_CB(set_heatingtype));
break;
case EMSdevice::EMS_DEVICE_FLAG_RC20:
register_device_value(tag, &hc->mode, DeviceValueType::ENUM, FL_(enum_mode2), FL_(mode), DeviceValueUOM::NONE, MAKE_CF_CB(set_mode));
register_device_value(tag,
Expand Down
1 change: 1 addition & 0 deletions src/devices/thermostat.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ class Thermostat : public EMSdevice {
void process_RC10Set(std::shared_ptr<const Telegram> telegram);
void process_RC10Set_2(std::shared_ptr<const Telegram> telegram);
void process_CRFMonitor(std::shared_ptr<const Telegram> telegram);
void process_CR11Monitor(std::shared_ptr<const Telegram> telegram);
void process_RC300Monitor(std::shared_ptr<const Telegram> telegram);
void process_RC300Set(std::shared_ptr<const Telegram> telegram);
void process_RC300Set2(std::shared_ptr<const Telegram> telegram);
Expand Down
1 change: 1 addition & 0 deletions src/emsdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ class EMSdevice {
static constexpr uint8_t EMS_DEVICE_FLAG_BC400 = 14; // mostly like RC300, but some changes
static constexpr uint8_t EMS_DEVICE_FLAG_R3000 = 15; // Rego3000, same as RC300 with different wwmodes
static constexpr uint8_t EMS_DEVICE_FLAG_CR120 = 16; // mostly like RC300, but some changes
static constexpr uint8_t EMS_DEVICE_FLAG_CR11 = 17; // CRF200 only monitor

uint8_t count_entities();
uint8_t count_entities_fav();
Expand Down
6 changes: 6 additions & 0 deletions src/web/WebStatusService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
}
return 0;
}();
time_t now = time(nullptr);
if (now > 1500000000L) {
char t[25];
strftime(t, sizeof(t), "%FT%T", localtime(&now));
root["ntp_time"] = t;
}
#endif

root["ap_status"] = EMSESP::esp8266React.apStatus();
Expand Down

0 comments on commit ba3ae5e

Please sign in to comment.