Skip to content

Commit

Permalink
Merge pull request #1869 from MichaelDvP/dev
Browse files Browse the repository at this point in the history
add RT800 remote #1867, use ems_bus_id for raw telegrams if src is not set(0)
  • Loading branch information
proddy authored Jul 18, 2024
2 parents a7dcb32 + f5e2bbf commit 5b4d392
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 21 deletions.
9 changes: 8 additions & 1 deletion src/devices/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,8 @@ bool Thermostat::set_remotetemp(const char * value, const int8_t id) {
Roomctrl::set_remotetemp(Roomctrl::RC100H, hc->hc(), hc->remotetemp); // RC100H
} else if (hc->control == 2) { // RC100(2)
Roomctrl::set_remotetemp(Roomctrl::RC100, hc->hc(), hc->remotetemp); // RC100
} else if (hc->control == 6) {
Roomctrl::set_remotetemp(Roomctrl::RT800, hc->hc(), hc->remotetemp);
} else {
hc->remotetemp = EMS_VALUE_INT16_NOTSET;
Roomctrl::set_remotetemp(0, hc->hc(), EMS_VALUE_INT16_NOTSET); // unknown remote set, switch off
Expand Down Expand Up @@ -1941,9 +1943,12 @@ bool Thermostat::set_remotehum(const char * value, const int8_t id) {
hc->remotehum = h;
}

if (hc->control == 3 && isRC300()) {
if (hc->control == 3) {
Roomctrl::set_remotehum(Roomctrl::RC100H, hc->hc(), hc->remotehum); // RC100H
return true;
} else if (hc->control == 6) {
Roomctrl::set_remotehum(Roomctrl::RT800, hc->hc(), hc->remotehum);
return true;
}
Roomctrl::set_remotehum(Roomctrl::RC100H, hc->hc(), EMS_VALUE_UINT8_NOTSET); // RC100H
return false;
Expand Down Expand Up @@ -2041,6 +2046,8 @@ bool Thermostat::set_control(const char * value, const int8_t id) {
Roomctrl::set_remotetemp(Roomctrl::RC100, hc->hc(), hc->remotetemp);
} else if (ctrl == 3) {
Roomctrl::set_remotetemp(Roomctrl::RC100H, hc->hc(), hc->remotetemp);
} else if (ctrl == 6) {
Roomctrl::set_remotetemp(Roomctrl::RT800, hc->hc(), hc->remotetemp);
} else {
hc->remotetemp = EMS_VALUE_INT16_NOTSET;
Roomctrl::set_remotetemp(0, hc->hc(), hc->remotetemp);
Expand Down
3 changes: 2 additions & 1 deletion src/locale_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ MAKE_NOTRANSLATION(rc100h, "RC100H")
MAKE_NOTRANSLATION(tc100, "TC100")
MAKE_NOTRANSLATION(rc120rf, "RC120RF")
MAKE_NOTRANSLATION(rc220, "RC220")
MAKE_NOTRANSLATION(rt800, "RT800")
MAKE_NOTRANSLATION(single, "single")
MAKE_NOTRANSLATION(dash, "-")
MAKE_NOTRANSLATION(BLANK, "")
Expand Down Expand Up @@ -346,7 +347,7 @@ MAKE_ENUM(enum_j_control, FL_(off), FL_(fb10), FL_(fb100))
MAKE_ENUM(enum_roomsensor, FL_(extern), FL_(intern), FL_(auto))
MAKE_ENUM(enum_roominfluence, FL_(off), FL_(intern), FL_(extern), FL_(auto))
MAKE_ENUM(enum_control1, FL_(rc310), FL_(rc200), FL_(rc100), FL_(rc100h), FL_(tc100))
MAKE_ENUM(enum_control2, FL_(off), FL_(dash), FL_(rc100), FL_(rc100h), FL_(dash), FL_(rc120rf), FL_(rc220), FL_(single)) // BC400
MAKE_ENUM(enum_control2, FL_(off), FL_(dash), FL_(rc100), FL_(rc100h), FL_(dash), FL_(rc120rf), FL_(rt800), FL_(single)) // BC400

MAKE_ENUM(enum_switchmode, FL_(off), FL_(eco), FL_(comfort), FL_(heat))

Expand Down
53 changes: 36 additions & 17 deletions src/roomcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void Roomctrl::set_remotetemp(const uint8_t type, const uint8_t hc, const int16_
sendtype_[hc] = SendType::TEMP;
return;
}
if (hc >= HCS || (type != RC20 && type != FB10 && type != RC100H && type != SENSOR && type != RC200 && type != RC100)) {
if (hc >= HCS || !type) {
return;
}
if (remotetemp_[hc] != temp) {
Expand All @@ -61,7 +61,7 @@ void Roomctrl::set_remotetemp(const uint8_t type, const uint8_t hc, const int16_

// set humidity for RC100H emulation
void Roomctrl::set_remotehum(const uint8_t type, const uint8_t hc, const int8_t hum) {
if (hc >= HCS || (type != RC100H) || type != type_[hc]) {
if (hc >= HCS || type != type_[hc]) {
return;
}
if (remotehum_[hc] != hum) {
Expand All @@ -75,7 +75,8 @@ uint8_t Roomctrl::get_hc(uint8_t addr) {
addr &= 0x7F;
if (addr >= 0x40 && addr <= 0x44 && type_[addr - 0x40] == SENSOR) {
return addr - 0x40; // SENSOR
} else if (addr >= 0x38 && addr <= 0x3B && (type_[addr - 0x38] == RC100H || type_[addr - 0x38] == RC200 || type_[addr - 0x38] == RC100)) {
} else if (addr >= 0x38 && addr <= 0x3B
&& (type_[addr - 0x38] == RC100H || type_[addr - 0x38] == RC200 || type_[addr - 0x38] == RC100 || type_[addr - 0x38] == RT800)) {
return addr - 0x38; // RC100H, RC200
} else if (addr >= 0x18 && addr <= 0x1B && (type_[addr - 0x18] == RC20 || type_[addr - 0x18] == FB10)) {
return addr - 0x18; // RC20, FB10
Expand Down Expand Up @@ -107,7 +108,7 @@ void Roomctrl::send(uint8_t addr) {
EMSESP::logger().warning("remotetemp timeout hc%d, stop sending roomtemperature to thermostat", hc);
}
if (switch_off_[hc] || (uuid::get_uptime() - send_time_[hc]) > SEND_INTERVAL) { // check interval
if (type_[hc] == RC100H) {
if (type_[hc] == RC100H || type_[hc] == RT800) {
if (sendtype_[hc] == SendType::HUMI) { // send humidity
if (switch_off_[hc]) {
remotehum_[hc] = EMS_VALUE_UINT8_NOTSET;
Expand Down Expand Up @@ -247,6 +248,12 @@ void Roomctrl::version(uint8_t addr, uint8_t dst, uint8_t hc) {
data[9] = EMSbus::calculate_crc(data, 9); // apppend CRC
EMSuart::transmit(data, 10);
return;
} else if (type_[hc] == RT800) {
data[5] = 21; // version 21.03
data[6] = 3;
data[7] = EMSbus::calculate_crc(data, 7); // apppend CRC
EMSuart::transmit(data, 8);
return;
}
}

Expand Down Expand Up @@ -279,7 +286,7 @@ void Roomctrl::unknown(uint8_t addr, uint8_t dst, uint8_t offset, uint8_t typeh,
* send the room temperature in message 0xAF
*/
void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
uint8_t data[12];
uint8_t data[14];
data[0] = addr | EMSbus::ems_mask();
data[1] = dst & 0x7F;
if (type_[hc] == RC20) { // RC20, telegram 0xAF
Expand Down Expand Up @@ -330,6 +337,20 @@ void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
data[7] = (uint8_t)(remotetemp_[hc] & 0xFF);
data[8] = EMSbus::calculate_crc(data, 8); // apppend CRC
EMSuart::transmit(data, 9);
} else if (type_[hc] == RT800) { // RC200, telegram 42B, ff
data[2] = 0xFF;
data[3] = 0;
data[4] = 3;
data[5] = 0x2B + hc;
data[6] = (uint8_t)(remotetemp_[hc] >> 8);
data[7] = (uint8_t)(remotetemp_[hc] & 0xFF);
uint16_t t1 = remotetemp_[hc] * 10 + 3;
data[8] = (uint8_t)(t1 >> 8);
data[9] = (uint8_t)(t1 & 0xFF);
data[10] = 1; // not sure what this is and if we need it, maybe mode?
data[11] = 9; // not sure what this is and if we need it, maybe mode?
data[12] = EMSbus::calculate_crc(data, 12); // apppend CRC
EMSuart::transmit(data, 13);
}
}

Expand All @@ -339,18 +360,16 @@ void Roomctrl::humidity(uint8_t addr, uint8_t dst, uint8_t hc) {
data[0] = addr | EMSbus::ems_mask();
data[1] = dst & 0x7F;
uint16_t dew = calc_dew(remotetemp_[hc], remotehum_[hc]);
if (type_[hc] == RC100H) { // RC100H, telegram 47B
data[2] = 0xFF;
data[3] = 0;
data[4] = 3;
data[5] = 0x7B + hc;
data[6] = dew == EMS_VALUE_INT16_NOTSET ? EMS_VALUE_INT8_NOTSET : (uint8_t)((dew + 5) / 10);
data[7] = remotehum_[hc];
data[8] = (uint8_t)(dew << 8);
data[9] = (uint8_t)(dew & 0xFF);
data[10] = EMSbus::calculate_crc(data, 10); // apppend CRC
EMSuart::transmit(data, 11);
}
data[2] = 0xFF;
data[3] = 0;
data[4] = 3;
data[5] = 0x7B + hc;
data[6] = dew == EMS_VALUE_INT16_NOTSET ? EMS_VALUE_INT8_NOTSET : (uint8_t)((dew + 5) / 10);
data[7] = remotehum_[hc];
data[8] = (uint8_t)(dew << 8);
data[9] = (uint8_t)(dew & 0xFF);
data[10] = EMSbus::calculate_crc(data, 10); // apppend CRC
EMSuart::transmit(data, 11);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/roomcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace emsesp {
class Roomctrl {
public:
// Product-Id of the remote
enum RemoteType : uint8_t { NONE = 0, RC20 = 113, FB10 = 109, RC100H = 200, SENSOR = 0x40, RC200 = 157, RC100 = 165 };
enum RemoteType : uint8_t { NONE = 0, RC20 = 113, FB10 = 109, RC100H = 200, SENSOR = 0x40, RC200 = 157, RC100 = 165, RT800 = 3 };

static void send(uint8_t addr);
static void check(uint8_t addr, const uint8_t * data, const uint8_t length);
Expand Down
2 changes: 1 addition & 1 deletion src/telegram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void TxService::add(uint8_t operation, const uint8_t * data, const uint8_t lengt
}

// build header. src, dest and offset have fixed positions
uint8_t src = operation == Telegram::Operation::TX_RAW ? data[0] : ems_bus_id();
uint8_t src = operation == Telegram::Operation::TX_RAW && data[0] ? data[0] : ems_bus_id();
uint8_t dest = data[1];
uint8_t offset = data[3];

Expand Down

0 comments on commit 5b4d392

Please sign in to comment.