remote emulation type for different hcs

This commit is contained in:
MichaelDvP
2024-04-12 09:09:02 +02:00
parent 8c6a45493b
commit 52704039ca
3 changed files with 50 additions and 46 deletions

View File

@@ -1867,6 +1867,10 @@ bool Thermostat::set_remotetemp(const char * value, const int8_t id) {
Roomctrl::set_remotetemp(Roomctrl::RC200, hc->hc(), hc->remotetemp); // RC200 Roomctrl::set_remotetemp(Roomctrl::RC200, hc->hc(), hc->remotetemp); // RC200
} else if (hc->control == 2 || hc->control == 3) { // RC100(2) and RC100H(3) } else if (hc->control == 2 || hc->control == 3) { // RC100(2) and RC100H(3)
Roomctrl::set_remotetemp(Roomctrl::RC100H, hc->hc(), hc->remotetemp); // RC100H Roomctrl::set_remotetemp(Roomctrl::RC100H, hc->hc(), hc->remotetemp); // RC100H
} else {
// test for #1691
// Roomctrl::set_remotetemp(Roomctrl::RC200, hc->hc(), hc->remotetemp); // RC200
Roomctrl::set_remotetemp(0, hc->hc(), EMS_VALUE_SHORT_NOTSET); // no remote set, switch off
} }
} }

View File

@@ -25,20 +25,27 @@ bool Roomctrl::switch_off_[HCS] = {false, false, false, false};
uint32_t Roomctrl::rc_time_[HCS] = {0, 0, 0, 0}; uint32_t Roomctrl::rc_time_[HCS] = {0, 0, 0, 0};
int16_t Roomctrl::remotetemp_[HCS] = {EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET}; int16_t Roomctrl::remotetemp_[HCS] = {EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET};
uint8_t Roomctrl::remotehum_[HCS] = {EMS_VALUE_UINT_NOTSET, EMS_VALUE_UINT_NOTSET, EMS_VALUE_UINT_NOTSET, EMS_VALUE_UINT_NOTSET}; uint8_t Roomctrl::remotehum_[HCS] = {EMS_VALUE_UINT_NOTSET, EMS_VALUE_UINT_NOTSET, EMS_VALUE_UINT_NOTSET, EMS_VALUE_UINT_NOTSET};
uint8_t Roomctrl::sendcnt[] = {0, 0, 0, 0}; uint8_t Roomctrl::sendcnt[HCS] = {0, 0, 0, 0};
uint8_t Roomctrl::type_ = RC20; uint8_t Roomctrl::type_[HCS] = {0, 0, 0, 0};
/** /**
* set the temperature, * set the temperature,
*/ */
void Roomctrl::set_remotetemp(const uint8_t type, const uint8_t hc, const int16_t temp) { void Roomctrl::set_remotetemp(const uint8_t type, const uint8_t hc, const int16_t temp) {
if (!type_[hc] && !type) {
return;
}
if (remotetemp_[hc] != EMS_VALUE_SHORT_NOTSET && temp == EMS_VALUE_SHORT_NOTSET) {
remotetemp_[hc] = EMS_VALUE_SHORT_NOTSET;
switch_off_[hc] = true;
rc_time_[hc] = uuid::get_uptime() - SEND_INTERVAL; // send now
sendcnt[hc] = 0;
return;
}
if (hc >= HCS || (type != RC20 && type != FB10 && type != RC100H && type != SENSOR && type != RC200)) { if (hc >= HCS || (type != RC20 && type != FB10 && type != RC100H && type != SENSOR && type != RC200)) {
return; return;
} }
type_ = type; type_[hc] = type;
if (remotetemp_[hc] != EMS_VALUE_SHORT_NOTSET && temp == EMS_VALUE_SHORT_NOTSET) {
switch_off_[hc] = true;
}
if (remotetemp_[hc] != temp) { if (remotetemp_[hc] != temp) {
rc_time_[hc] = uuid::get_uptime() - SEND_INTERVAL; // send now rc_time_[hc] = uuid::get_uptime() - SEND_INTERVAL; // send now
sendcnt[hc] = 0; sendcnt[hc] = 0;
@@ -46,14 +53,11 @@ void Roomctrl::set_remotetemp(const uint8_t type, const uint8_t hc, const int16_
remotetemp_[hc] = temp; remotetemp_[hc] = temp;
} }
// set humidity for RC100H emulation
void Roomctrl::set_remotehum(const uint8_t type, const uint8_t hc, const int8_t hum) { void Roomctrl::set_remotehum(const uint8_t type, const uint8_t hc, const int8_t hum) {
if (hc >= HCS || (type != RC20 && type != FB10 && type != RC100H && type != SENSOR)) { if (hc >= HCS || (type != RC100H) || type != type_[hc]) {
return; return;
} }
type_ = type;
if (remotehum_[hc] != EMS_VALUE_UINT_NOTSET && (uint8_t)hum == EMS_VALUE_UINT_NOTSET) {
switch_off_[hc] = true;
}
if (remotehum_[hc] != hum) { if (remotehum_[hc] != hum) {
rc_time_[hc] = uuid::get_uptime() - SEND_INTERVAL; // send now rc_time_[hc] = uuid::get_uptime() - SEND_INTERVAL; // send now
sendcnt[hc] = 1; sendcnt[hc] = 1;
@@ -63,17 +67,14 @@ void Roomctrl::set_remotehum(const uint8_t type, const uint8_t hc, const int8_t
uint8_t Roomctrl::get_hc(uint8_t addr) { uint8_t Roomctrl::get_hc(uint8_t addr) {
addr &= 0x7F; addr &= 0x7F;
switch (type_) { if (addr >= 0x40 && addr <= 0x44) {
case SENSOR: return addr - 0x40; // SENSOR
return addr - 0x40; } else if (addr >= 0x38 && addr <= 0x3B) {
case RC200: return addr - 0x38; // RC100H, RC200
case RC100H: } else if (addr >= 0x18 && addr <= 0x1B) {
return addr - 0x38; return addr - 0x18; // RC20, FB10
case FB10:
case RC20:
default:
return addr - 0x18;
} }
return 0xFF; // invalid
} }
/** /**
@@ -92,7 +93,7 @@ void Roomctrl::send(uint8_t addr) {
} }
if (uuid::get_uptime() - rc_time_[hc] > SEND_INTERVAL) { // send every minute if (uuid::get_uptime() - rc_time_[hc] > SEND_INTERVAL) { // send every minute
if (type_ == RC100H) { if (type_[hc] == RC100H) {
if (sendcnt[hc] == 1) { // second telegram for humidity if (sendcnt[hc] == 1) { // second telegram for humidity
if (switch_off_[hc]) { if (switch_off_[hc]) {
remotehum_[hc] = EMS_VALUE_UINT_NOTSET; remotehum_[hc] = EMS_VALUE_UINT_NOTSET;
@@ -108,18 +109,19 @@ void Roomctrl::send(uint8_t addr) {
} }
temperature(addr, 0x10, hc); // send to master-thermostat temperature(addr, 0x10, hc); // send to master-thermostat
} }
} else if (type_ == RC200) { } else if (type_[hc] == RC200) {
rc_time_[hc] = uuid::get_uptime(); rc_time_[hc] = uuid::get_uptime();
temperature(addr, 0x10, hc); temperature(addr, 0x10, hc);
} else if (type_ == FB10) { } else if (type_[hc] == FB10) {
rc_time_[hc] = uuid::get_uptime(); rc_time_[hc] = uuid::get_uptime();
temperature(addr, 0x10, hc); // send to master-thermostat (https://github.com/emsesp/EMS-ESP32/issues/336) temperature(addr, 0x10, hc); // send to master-thermostat (https://github.com/emsesp/EMS-ESP32/issues/336)
} else { // type==RC20 or SENSOR } else { // type==RC20 or SENSOR
rc_time_[hc] = uuid::get_uptime(); rc_time_[hc] = uuid::get_uptime();
temperature(addr, 0x00, hc); // send to all temperature(addr, 0x00, hc); // send to all
} }
if (remotehum_[hc] == EMS_VALUE_UINT_NOTSET) { if (remotehum_[hc] == EMS_VALUE_UINT_NOTSET && switch_off_[hc]) {
switch_off_[hc] = false; switch_off_[hc] = false;
type_[hc] = 0;
} }
} else { } else {
// acknowledge every poll, otherwise the master shows error A22-816 // acknowledge every poll, otherwise the master shows error A22-816
@@ -131,13 +133,11 @@ void Roomctrl::send(uint8_t addr) {
* check if there is a message for the remote room controller * check if there is a message for the remote room controller
*/ */
void Roomctrl::check(uint8_t addr, const uint8_t * data, const uint8_t length) { void Roomctrl::check(uint8_t addr, const uint8_t * data, const uint8_t length) {
if (type_ == SENSOR) { uint8_t hc = get_hc(addr);
if (hc >= HCS || length < 5) {
return; return;
} }
if (type_[hc] == SENSOR) {
uint8_t hc = get_hc(addr);
// check address, reply only on addresses 0x18..0x1B
if (hc >= HCS || length < 5) {
return; return;
} }
// no reply if the temperature is not set // no reply if the temperature is not set
@@ -153,7 +153,7 @@ void Roomctrl::check(uint8_t addr, const uint8_t * data, const uint8_t length) {
// reads: for now we only reply to version and remote temperature // reads: for now we only reply to version and remote temperature
// empty message back if temperature not set or unknown message type // empty message back if temperature not set or unknown message type
if (data[2] == EMSdevice::EMS_TYPE_VERSION) { if (data[2] == EMSdevice::EMS_TYPE_VERSION) {
version(addr, data[0]); version(addr, data[0], hc);
} else if (length == 6 && remotetemp_[hc] == EMS_VALUE_SHORT_NOTSET) { } else if (length == 6 && remotetemp_[hc] == EMS_VALUE_SHORT_NOTSET) {
unknown(addr, data[0], data[2], data[3]); unknown(addr, data[0], data[2], data[3]);
} else if (length == 8 && remotetemp_[hc] == EMS_VALUE_SHORT_NOTSET) { } else if (length == 8 && remotetemp_[hc] == EMS_VALUE_SHORT_NOTSET) {
@@ -174,22 +174,22 @@ void Roomctrl::check(uint8_t addr, const uint8_t * data, const uint8_t length) {
} }
/** /**
* send version info RC20 (Prod. 113, Ver. 02.01) or RC20RF (Prod. 93, Ver. 02.00) * send version info
*/ */
void Roomctrl::version(uint8_t addr, uint8_t dst) { void Roomctrl::version(uint8_t addr, uint8_t dst, uint8_t hc) {
uint8_t data[20]; uint8_t data[20];
data[0] = addr | EMSbus::ems_mask(); data[0] = addr | EMSbus::ems_mask();
data[1] = dst & 0x7F; data[1] = dst & 0x7F;
data[2] = 0x02; data[2] = 0x02;
data[3] = 0; data[3] = 0;
data[4] = type_; // set RC20 id 113, Ver 02.01 or Junkers FB10 id 109, Ver 16.05, RC100H id 200 ver 40.04 data[4] = type_[hc]; // set RC20 id 113, Ver 02.01 or Junkers FB10 id 109, Ver 16.05, RC100H id 200 ver 40.04
if (type_ == RC20) { if (type_[hc] == RC20) {
data[5] = 2; // version 2.01 data[5] = 2; // version 2.01
data[6] = 1; data[6] = 1;
data[7] = EMSbus::calculate_crc(data, 7); // apppend CRC data[7] = EMSbus::calculate_crc(data, 7); // apppend CRC
EMSuart::transmit(data, 8); EMSuart::transmit(data, 8);
return; return;
} else if (type_ == FB10) { } else if (type_[hc] == FB10) {
data[5] = 16; // version 16.05 data[5] = 16; // version 16.05
data[6] = 5; data[6] = 5;
data[7] = 0; data[7] = 0;
@@ -202,7 +202,7 @@ void Roomctrl::version(uint8_t addr, uint8_t dst) {
data[14] = EMSbus::calculate_crc(data, 14); // apppend CRC data[14] = EMSbus::calculate_crc(data, 14); // apppend CRC
EMSuart::transmit(data, 15); EMSuart::transmit(data, 15);
return; return;
} else if (type_ == RC200) { } else if (type_[hc] == RC200) {
data[5] = 32; // version 32.02 see #1611 data[5] = 32; // version 32.02 see #1611
data[6] = 2; data[6] = 2;
data[7] = 0; data[7] = 0;
@@ -215,7 +215,7 @@ void Roomctrl::version(uint8_t addr, uint8_t dst) {
data[14] = EMSbus::calculate_crc(data, 14); // apppend CRC data[14] = EMSbus::calculate_crc(data, 14); // apppend CRC
EMSuart::transmit(data, 15); EMSuart::transmit(data, 15);
return; return;
} else if (type_ == RC100H) { } else if (type_[hc] == RC100H) {
data[5] = 40; // version 40.04 data[5] = 40; // version 40.04
data[6] = 4; data[6] = 4;
data[7] = 0; data[7] = 0;
@@ -258,7 +258,7 @@ void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
uint8_t data[12]; uint8_t data[12];
data[0] = addr | EMSbus::ems_mask(); data[0] = addr | EMSbus::ems_mask();
data[1] = dst & 0x7F; data[1] = dst & 0x7F;
if (type_ == RC20) { // RC20, telegram 0xAF if (type_[hc] == RC20) { // RC20, telegram 0xAF
data[2] = 0xAF; data[2] = 0xAF;
data[3] = 0; data[3] = 0;
data[4] = (uint8_t)(remotetemp_[hc] >> 8); data[4] = (uint8_t)(remotetemp_[hc] >> 8);
@@ -266,7 +266,7 @@ void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
data[6] = 0; data[6] = 0;
data[7] = EMSbus::calculate_crc(data, 7); // apppend CRC data[7] = EMSbus::calculate_crc(data, 7); // apppend CRC
EMSuart::transmit(data, 8); EMSuart::transmit(data, 8);
} else if (type_ == FB10) { // Junkers FB10, telegram 0x0123 } else if (type_[hc] == FB10) { // Junkers FB10, telegram 0x0123
data[2] = 0xFF; data[2] = 0xFF;
data[3] = 0; data[3] = 0;
data[4] = 0; data[4] = 0;
@@ -275,7 +275,7 @@ void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
data[7] = (uint8_t)(remotetemp_[hc] & 0xFF); data[7] = (uint8_t)(remotetemp_[hc] & 0xFF);
data[8] = EMSbus::calculate_crc(data, 8); // apppend CRC data[8] = EMSbus::calculate_crc(data, 8); // apppend CRC
EMSuart::transmit(data, 9); EMSuart::transmit(data, 9);
} else if (type_ == RC200) { // RC200, telegram 42B, ff } else if (type_[hc] == RC200) { // RC200, telegram 42B, ff
data[2] = 0xFF; data[2] = 0xFF;
data[3] = 0; data[3] = 0;
data[4] = 3; data[4] = 3;
@@ -288,7 +288,7 @@ void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
data[10] = 1; // not sure what this is and if we need it, maybe mode? data[10] = 1; // not sure what this is and if we need it, maybe mode?
data[11] = EMSbus::calculate_crc(data, 11); // apppend CRC data[11] = EMSbus::calculate_crc(data, 11); // apppend CRC
EMSuart::transmit(data, 12); EMSuart::transmit(data, 12);
} else if (type_ == RC100H) { // RC100H, telegram 42B, ff } else if (type_[hc] == RC100H) { // RC100H, telegram 42B, ff
data[2] = 0xFF; data[2] = 0xFF;
data[3] = 0; data[3] = 0;
data[4] = 3; data[4] = 3;
@@ -297,7 +297,7 @@ void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
data[7] = (uint8_t)(remotetemp_[hc] & 0xFF); data[7] = (uint8_t)(remotetemp_[hc] & 0xFF);
data[8] = EMSbus::calculate_crc(data, 8); // apppend CRC data[8] = EMSbus::calculate_crc(data, 8); // apppend CRC
EMSuart::transmit(data, 9); EMSuart::transmit(data, 9);
} else if (type_ == SENSOR) { // wireless sensor, broadcast id 435 } else if (type_[hc] == SENSOR) { // wireless sensor, broadcast id 435
data[2] = 0xFF; data[2] = 0xFF;
data[3] = 0; data[3] = 0;
data[4] = 3; data[4] = 3;
@@ -315,7 +315,7 @@ void Roomctrl::humidity(uint8_t addr, uint8_t dst, uint8_t hc) {
data[0] = addr | EMSbus::ems_mask(); data[0] = addr | EMSbus::ems_mask();
data[1] = dst & 0x7F; data[1] = dst & 0x7F;
uint16_t dew = calc_dew(remotetemp_[hc], remotehum_[hc]); uint16_t dew = calc_dew(remotetemp_[hc], remotehum_[hc]);
if (type_ == RC100H) { // RC100H, telegram 47B if (type_[hc] == RC100H) { // RC100H, telegram 47B
data[2] = 0xFF; data[2] = 0xFF;
data[3] = 0; data[3] = 0;
data[4] = 3; data[4] = 3;

View File

@@ -39,7 +39,7 @@ class Roomctrl {
static constexpr uint8_t HCS = 4; // max 4 heating circuits static constexpr uint8_t HCS = 4; // max 4 heating circuits
static uint8_t get_hc(const uint8_t addr); static uint8_t get_hc(const uint8_t addr);
static void version(uint8_t addr, uint8_t dst); static void version(uint8_t addr, uint8_t dst, uint8_t hc);
static void unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset); static void unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset);
static void unknown(uint8_t addr, uint8_t dst, uint8_t offset, uint8_t typeh, uint8_t typel); static void unknown(uint8_t addr, uint8_t dst, uint8_t offset, uint8_t typeh, uint8_t typel);
static void temperature(uint8_t addr, uint8_t dst, uint8_t hc); static void temperature(uint8_t addr, uint8_t dst, uint8_t hc);
@@ -53,7 +53,7 @@ class Roomctrl {
static int16_t remotetemp_[HCS]; static int16_t remotetemp_[HCS];
static uint8_t remotehum_[HCS]; static uint8_t remotehum_[HCS];
static uint8_t sendcnt[HCS]; static uint8_t sendcnt[HCS];
static uint8_t type_; // type is product-id 113 for RC20 or 109 for Junkers FB10 static uint8_t type_[HCS]; // type is product-id 113 for RC20 or 109 for Junkers FB10
}; };
} // namespace emsesp } // namespace emsesp