From 8ab319dcbb18e5a7b5c35e2d014c8a3c38b4d2bf Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Wed, 17 Jun 2020 12:11:30 +0200 Subject: [PATCH] ems+ empty messages, Flags for solar modules, roomtemp from remote thermostats --- src/device_library.h | 2 +- src/devices/solar.cpp | 32 +++++++++++++++++++------------- src/devices/thermostat.cpp | 13 +++++++++++++ src/devices/thermostat.h | 1 + src/emsdevice.h | 1 + src/telegram.cpp | 12 +++--------- 6 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/device_library.h b/src/device_library.h index e08d07d4e..10c59649c 100644 --- a/src/device_library.h +++ b/src/device_library.h @@ -71,7 +71,7 @@ // Solar Modules - 0x30 { 73, DeviceType::SOLAR, F("SM10"), DeviceFlags::EMS_DEVICE_FLAG_SM10}, -{101, DeviceType::SOLAR, F("ISM1"), DeviceFlags::EMS_DEVICE_FLAG_SM100}, +{101, DeviceType::SOLAR, F("ISM1"), DeviceFlags::EMS_DEVICE_FLAG_ISM}, {162, DeviceType::SOLAR, F("SM50"), DeviceFlags::EMS_DEVICE_FLAG_SM100}, {163, DeviceType::SOLAR, F("SM100"), DeviceFlags::EMS_DEVICE_FLAG_SM100}, {164, DeviceType::SOLAR, F("SM200"), DeviceFlags::EMS_DEVICE_FLAG_SM100}, diff --git a/src/devices/solar.cpp b/src/devices/solar.cpp index 7a9381d67..ba4f0bbff 100644 --- a/src/devices/solar.cpp +++ b/src/devices/solar.cpp @@ -33,16 +33,22 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const s LOG_DEBUG(F("Registering new Solar module with device ID 0x%02X"), device_id); // telegram handlers - register_telegram_type(0x0097, F("SM10Monitor"), true, std::bind(&Solar::process_SM10Monitor, this, _1)); - register_telegram_type(0x0362, F("SM100Monitor"), true, std::bind(&Solar::process_SM100Monitor, this, _1)); - register_telegram_type(0x0363, F("SM100Monitor2"), true, std::bind(&Solar::process_SM100Monitor2, this, _1)); - register_telegram_type(0x0366, F("SM100Config"), true, std::bind(&Solar::process_SM100Config, this, _1)); + if (flags == EMSdevice::EMS_DEVICE_FLAG_SM10) { + register_telegram_type(0x0097, F("SM10Monitor"), true, std::bind(&Solar::process_SM10Monitor, this, _1)); + } + if (flags == EMSdevice::EMS_DEVICE_FLAG_SM100) { + register_telegram_type(0x0362, F("SM100Monitor"), true, std::bind(&Solar::process_SM100Monitor, this, _1)); + register_telegram_type(0x0363, F("SM100Monitor2"), true, std::bind(&Solar::process_SM100Monitor2, this, _1)); + register_telegram_type(0x0366, F("SM100Config"), true, std::bind(&Solar::process_SM100Config, this, _1)); - register_telegram_type(0x0364, F("SM100Status"), false, std::bind(&Solar::process_SM100Status, this, _1)); - register_telegram_type(0x036A, F("SM100Status2"), false, std::bind(&Solar::process_SM100Status2, this, _1)); - register_telegram_type(0x038E, F("SM100Energy"), true, std::bind(&Solar::process_SM100Energy, this, _1)); - register_telegram_type(0x0103, F("ISM1StatusMessage"), true, std::bind(&Solar::process_ISM1StatusMessage, this, _1)); - register_telegram_type(0x0101, F("ISM1Set"), false, std::bind(&Solar::process_ISM1Set, this, _1)); + register_telegram_type(0x0364, F("SM100Status"), false, std::bind(&Solar::process_SM100Status, this, _1)); + register_telegram_type(0x036A, F("SM100Status2"), false, std::bind(&Solar::process_SM100Status2, this, _1)); + register_telegram_type(0x038E, F("SM100Energy"), true, std::bind(&Solar::process_SM100Energy, this, _1)); + } + if (flags == EMSdevice::EMS_DEVICE_FLAG_ISM) { + register_telegram_type(0x0103, F("ISM1StatusMessage"), true, std::bind(&Solar::process_ISM1StatusMessage, this, _1)); + register_telegram_type(0x0101, F("ISM1Set"), false, std::bind(&Solar::process_ISM1Set, this, _1)); + } // MQTT callbacks // register_mqtt_topic("cmd", std::bind(&Solar::cmd, this, _1)); @@ -204,10 +210,10 @@ void Solar::process_SM100Energy(std::shared_ptr telegram) { * e.g. B0 00 FF 00 00 03 32 00 00 00 00 13 00 D6 00 00 00 FB D0 F0 */ void Solar::process_ISM1StatusMessage(std::shared_ptr telegram) { - telegram->read_value(collectorTemp_, 4); // Collector Temperature - telegram->read_value(bottomTemp_, 6); // Temperature Bottom of Solar Boiler - telegram->read_value(energyLastHour_, 2); // Solar Energy produced in last hour - is * 10 and handled in ems-esp.cpp - telegram->read_value(pump_, 8, 0); // Solar pump on (1) or off (0) + telegram->read_value(collectorTemp_, 4); // Collector Temperature + telegram->read_value(bottomTemp_, 6); // Temperature Bottom of Solar Boiler + telegram->read_value32(energyLastHour_, 0); // Solar Energy produced in last hour - is * 10 and handled in ems-esp.cpp + telegram->read_value(pump_, 8, 0); // Solar pump on (1) or off (0) telegram->read_value(pumpWorkMin_, 10); } diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index f0bd83f6a..b9ab96d8e 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -67,6 +67,7 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i register_telegram_type(monitor_typeids[i], F("RC20Monitor"), false, std::bind(&Thermostat::process_RC20Monitor, this, _1)); register_telegram_type(set_typeids[i], F("RC20Set"), false, std::bind(&Thermostat::process_RC20Set, this, _1)); } + register_telegram_type(0xAF, F("RC20Remote"), false, std::bind(&Thermostat::process_RC20Remote, this, _1)); // RC20 newer } else if (flags == EMSdevice::EMS_DEVICE_FLAG_RC20_2) { @@ -76,6 +77,7 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i register_telegram_type(monitor_typeids[i], F("RC20Monitor"), false, std::bind(&Thermostat::process_RC20Monitor_2, this, _1)); register_telegram_type(set_typeids[i], F("RC20Set"), false, std::bind(&Thermostat::process_RC20Set_2, this, _1)); } + register_telegram_type(0xAF, F("RC20Remote"), false, std::bind(&Thermostat::process_RC20Remote, this, _1)); // RC30 } else if (flags == EMSdevice::EMS_DEVICE_FLAG_RC30) { @@ -655,6 +657,11 @@ std::shared_ptr Thermostat::heating_circuit(std::sha } } + // not found, search device-id types for remote thermostats + if (telegram->src >= 0x18 && telegram->src <= 0x1B) { + hc_num = telegram->src - 0x17; + } + // still didn't recognize it, ignore it if (hc_num == 0) { return nullptr; @@ -950,6 +957,12 @@ void Thermostat::process_RC20Set_2(std::shared_ptr telegram) { telegram->read_value(hc->mode, 3); } +// 0xAF - for reading the roomtemperature from the RC20/ES72 thermostat (0x18, 0x19, ..) +void Thermostat::process_RC20Remote(std::shared_ptr telegram) { + std::shared_ptr hc = heating_circuit(telegram); + telegram->read_value(hc->curr_roomTemp, 0); +} + // type 0xB1 - data from the RC10 thermostat (0x17) void Thermostat::process_RC10Monitor(std::shared_ptr telegram) { std::shared_ptr hc = heating_circuit(telegram); diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index 018daf8f9..732632684 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -216,6 +216,7 @@ class Thermostat : public EMSdevice { void process_RC20Monitor(std::shared_ptr telegram); void process_RC20Set(std::shared_ptr telegram); + void process_RC20Remote(std::shared_ptr telegram); void process_RC20Monitor_2(std::shared_ptr telegram); void process_RC20Set_2(std::shared_ptr telegram); diff --git a/src/emsdevice.h b/src/emsdevice.h index b0259e590..527d856c2 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -181,6 +181,7 @@ class EMSdevice { // Solar Module static constexpr uint8_t EMS_DEVICE_FLAG_SM10 = 1; static constexpr uint8_t EMS_DEVICE_FLAG_SM100 = 2; + static constexpr uint8_t EMS_DEVICE_FLAG_ISM = 3; // Mixing Module static constexpr uint8_t EMS_DEVICE_FLAG_MMPLUS = 1; diff --git a/src/telegram.cpp b/src/telegram.cpp index cc4fb0335..d3f4a853d 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -279,15 +279,9 @@ void RxService::add(uint8_t * data, uint8_t length) { } else { // EMS 2.0 / EMS+ if (data[2] == 0xFF) { - // check for empty data - // special broadcast telegrams on ems+ have no data values, some even don't have a type ID, e.g. "21 0B FF 00" - if (length > 8) { - message_length -= 7; // remove 6 byte header plus CRC - message_data += 6; // message block starts at 7th position - } - if (length > 5) { - type_id = (data[4] << 8) + data[5] + 256; // set type_id if there is one - } + message_length -= 7; // remove 6 byte header plus CRC + message_data += 6; // message block starts at 7th position + type_id = (data[4] << 8) + data[5] + 256; // set type_id if there is one } else { // its F9 or F7 uint8_t shift = (data[4] != 0xFF) ? 1 : 0; // true (1) if 5th byte is not 0xFF, then telegram is 1 byte longer