diff --git a/src/roomcontrol.cpp b/src/roomcontrol.cpp index 694730a97..b85dcaa76 100644 --- a/src/roomcontrol.cpp +++ b/src/roomcontrol.cpp @@ -25,8 +25,8 @@ bool Roomctrl::switch_off_[HCS] = {false, false, false, false}; 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}; 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[HCS] = {0, 0, 0, 0}; -uint8_t Roomctrl::type_[HCS] = {0, 0, 0, 0}; +uint8_t Roomctrl::sendtype_[HCS] = {SendType::TEMP, SendType::TEMP, SendType::TEMP, SendType::TEMP}; +uint8_t Roomctrl::type_[HCS] = {RemoteType::NONE, RemoteType::NONE, RemoteType::NONE, RemoteType::NONE}; /** * set the temperature, @@ -35,11 +35,11 @@ void Roomctrl::set_remotetemp(const uint8_t type, const uint8_t hc, const int16_ if (!type_[hc] && !type) { return; } - if (remotetemp_[hc] != EMS_VALUE_SHORT_NOTSET && temp == EMS_VALUE_SHORT_NOTSET) { + if (remotetemp_[hc] != EMS_VALUE_SHORT_NOTSET && temp == EMS_VALUE_SHORT_NOTSET) { // switch remote off remotetemp_[hc] = EMS_VALUE_SHORT_NOTSET; switch_off_[hc] = true; rc_time_[hc] = uuid::get_uptime() - SEND_INTERVAL; // send now - sendcnt[hc] = 0; + sendtype_[hc] = SendType::TEMP; return; } if (hc >= HCS || (type != RC20 && type != FB10 && type != RC100H && type != SENSOR && type != RC200 && type != RC100)) { @@ -47,8 +47,8 @@ void Roomctrl::set_remotetemp(const uint8_t type, const uint8_t hc, const int16_ } type_[hc] = type; if (remotetemp_[hc] != temp) { - rc_time_[hc] = uuid::get_uptime() - SEND_INTERVAL; // send now - sendcnt[hc] = 0; + rc_time_[hc] = uuid::get_uptime() - SEND_INTERVAL; // send now + sendtype_[hc] = SendType::TEMP; } remotetemp_[hc] = temp; } @@ -59,8 +59,8 @@ void Roomctrl::set_remotehum(const uint8_t type, const uint8_t hc, const int8_t return; } if (remotehum_[hc] != hum) { - rc_time_[hc] = uuid::get_uptime() - SEND_INTERVAL; // send now - sendcnt[hc] = 1; + rc_time_[hc] = uuid::get_uptime() - SEND_INTERVAL; // send now + sendtype_[hc] = SendType::HUMI; } remotehum_[hc] = hum; } @@ -78,7 +78,7 @@ uint8_t Roomctrl::get_hc(uint8_t addr) { } /** - * if remote control is active send the temperature every minute + * if remote control is active send the temperature every 15 seconds */ void Roomctrl::send(uint8_t addr) { addr &= 0x7F; @@ -92,18 +92,18 @@ void Roomctrl::send(uint8_t addr) { return; } - if (uuid::get_uptime() - rc_time_[hc] > SEND_INTERVAL) { // send every minute + if (uuid::get_uptime() - rc_time_[hc] > SEND_INTERVAL) { // check interval if (type_[hc] == RC100H) { - if (sendcnt[hc] == 1) { // second telegram for humidity + if (sendtype_[hc] == SendType::HUMI) { // send humidity if (switch_off_[hc]) { remotehum_[hc] = EMS_VALUE_UINT_NOTSET; } rc_time_[hc] = uuid::get_uptime(); humidity(addr, 0x10, hc); - sendcnt[hc] = 0; + sendtype_[hc] = SendType::TEMP; } else { // temperature telegram if (remotehum_[hc] != EMS_VALUE_UINT_NOTSET) { - sendcnt[hc] = 1; + sendtype_[hc] = SendType::HUMI; } else { rc_time_[hc] = uuid::get_uptime(); } @@ -121,11 +121,12 @@ void Roomctrl::send(uint8_t addr) { } if (remotehum_[hc] == EMS_VALUE_UINT_NOTSET && switch_off_[hc]) { switch_off_[hc] = false; - type_[hc] = 0; + type_[hc] = RemoteType::NONE; } } else { // acknowledge every poll, otherwise the master shows error A22-816 - EMSuart::send_poll(addr | EMSbus::ems_mask()); + // not needed for 15 sec repeat rate, causes incomplete telegrams if poll-ack is sent + // EMSuart::send_poll(addr | EMSbus::ems_mask()); } } diff --git a/src/roomcontrol.h b/src/roomcontrol.h index 1ebe2b24a..9a1414f75 100644 --- a/src/roomcontrol.h +++ b/src/roomcontrol.h @@ -24,19 +24,21 @@ 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 }; + static void send(uint8_t addr); static void check(uint8_t addr, const uint8_t * data, const uint8_t length); static void set_remotetemp(const uint8_t type, const uint8_t hc, const int16_t temp); static void set_remotehum(const uint8_t type, const uint8_t hc, const int8_t hum); - enum : uint8_t { RC20 = 113, FB10 = 109, RC100H = 200, SENSOR = 0x40, RC200 = 157, RC100 = 165 }; static bool is_remote(const uint8_t hc) { return (hc < 4 && remotetemp_[hc] != EMS_VALUE_SHORT_NOTSET); } private: - static constexpr uint8_t ADDR = 0x18; // address for hc1 - static constexpr uint32_t SEND_INTERVAL = 15000; // ~1/4 minute + static constexpr uint32_t SEND_INTERVAL = 15000; // 15 sec static constexpr uint8_t HCS = 4; // max 4 heating circuits + enum SendType : uint8_t { TEMP, HUMI }; static uint8_t get_hc(const uint8_t addr); static void version(uint8_t addr, uint8_t dst, uint8_t hc); @@ -52,7 +54,7 @@ class Roomctrl { static uint32_t rc_time_[HCS]; static int16_t remotetemp_[HCS]; static uint8_t remotehum_[HCS]; - static uint8_t sendcnt[HCS]; + static uint8_t sendtype_[HCS]; static uint8_t type_[HCS]; // type is product-id 113 for RC20 or 109 for Junkers FB10 };