From 4805fb6c46d91f2a3d7c5947329a6a57e541b4d5 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 14 Nov 2020 00:01:56 +0100 Subject: [PATCH 1/6] don't send shower MQTT if MQTT disabled --- src/shower.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shower.cpp b/src/shower.cpp index be67e0067..4d1a2559d 100644 --- a/src/shower.cpp +++ b/src/shower.cpp @@ -28,7 +28,9 @@ void Shower::start() { shower_alert_ = settings.shower_alert; }); - send_mqtt_stat(false); // send first MQTT publish + if (Mqtt::enabled()) { + send_mqtt_stat(false); // send first MQTT publish + } } void Shower::loop() { From 716cbf7e861d730ae162b2aa3c6b3b092dc78f19 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 14 Nov 2020 00:02:12 +0100 Subject: [PATCH 2/6] updated --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1176cfd07..aafac8a94 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ firmware /lib/framework/WWWData.h /interface/build/ /interface/node_modules/ +.VSCodeCounter/ From 055504381069e904a61a9a20e6ce2db0f427de49 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 14 Nov 2020 00:03:04 +0100 Subject: [PATCH 3/6] text changes --- src/dallassensor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dallassensor.cpp b/src/dallassensor.cpp index b1a0bf53c..940e6e74e 100644 --- a/src/dallassensor.cpp +++ b/src/dallassensor.cpp @@ -84,12 +84,12 @@ void DallasSensor::loop() { bus_.reset_search(); state_ = State::SCANNING; } else if (time_now - last_activity_ > READ_TIMEOUT_MS) { - LOG_ERROR(F("Sensor read timeout")); + LOG_WARNING(F("Dallas sensor read timeout")); state_ = State::IDLE; } } else if (state_ == State::SCANNING) { if (time_now - last_activity_ > SCAN_TIMEOUT_MS) { - LOG_ERROR(F("Sensor scan timeout")); + LOG_ERROR(F("Dallas sensor scan timeout")); state_ = State::IDLE; } else { uint8_t addr[ADDR_LEN] = {0}; @@ -129,11 +129,11 @@ void DallasSensor::loop() { break; default: - LOG_ERROR(F("Unknown sensor %s"), Sensor(addr).to_string().c_str()); + LOG_ERROR(F("Unknown dallas sensor %s"), Sensor(addr).to_string().c_str()); break; } } else { - LOG_ERROR(F("Invalid sensor %s"), Sensor(addr).to_string().c_str()); + LOG_ERROR(F("Invalid dallas sensor %s"), Sensor(addr).to_string().c_str()); } } else { if (!parasite_) { From 8bd7b21f30ecb5f7aff69e8391d6caaa9e6f0d3d Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 14 Nov 2020 00:05:00 +0100 Subject: [PATCH 4/6] minor updates --- src/test/test.cpp | 175 ++++++++++++++++++++-------------------------- src/test/test.h | 3 +- 2 files changed, 76 insertions(+), 102 deletions(-) diff --git a/src/test/test.cpp b/src/test/test.cpp index b4dbb0bf4..bc67357c7 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -27,10 +27,10 @@ namespace emsesp { // used with the 'test' command, under su/admin void Test::run_test(uuid::console::Shell & shell, const std::string & command) { // switch to su - shell.add_flags(CommandFlags::ADMIN); + // shell.add_flags(CommandFlags::ADMIN); if (command == "default") { - run_test(shell, "general"); // add the default test case here + run_test(shell, "boiler"); // add the default test case here } if (command.empty()) { @@ -38,6 +38,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { } if (command == "render") { + shell.printfln(F("Testing render...")); + uint8_t test1 = 12; int8_t test2 = -12; uint16_t test3 = 456; @@ -133,6 +135,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { } if (command == "devices") { + shell.printfln(F("Testing devices...")); + EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); // this is important otherwise nothing will be picked up! //emsdevices.push_back(EMSFactory::add(EMSdevice::DeviceType::BOILER, EMSdevice::EMS_DEVICE_ID_BOILER, 0, "", "My Boiler", 0, 0)); @@ -141,39 +145,29 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { rx_telegram({0x08, 0x00, 0x07, 0x00, 0x0B, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); } - if (command == "boiler") { - // question: do we need to set the mask? - std::string version("1.2.3"); - EMSESP::add_device(0x08, 123, version, EMSdevice::Brand::BUDERUS); // Nefit Trendline - - // UBAuptime - uart_telegram({0x08, 0x0B, 0x14, 00, 0x3C, 0x1F, 0xAC, 0x70}); - - shell.invoke_command("show"); - shell.invoke_command("call boiler info"); - } - // check for boiler and controller on same product_id if (command == "double") { - // question: do we need to set the mask? - std::string version("1.2.3"); - EMSESP::add_device(0x08, 206, version, EMSdevice::Brand::BUDERUS); // Nefit Excellent HR30 - EMSESP::add_device(0x09, 206, version, EMSdevice::Brand::BUDERUS); // Nefit Excellent HR30 Controller + shell.printfln(F("Testing double...")); + + add_device(0x08, 206); // Nefit Excellent HR30 + add_device(0x09, 206); // Nefit Excellent HR30 Controller // UBAuptime uart_telegram({0x08, 0x0B, 0x14, 00, 0x3C, 0x1F, 0xAC, 0x70}); } - // unknown device - + // unknown device if (command == "unknown") { + shell.printfln(F("Testing unknown...")); + // question: do we need to set the mask? std::string version("1.2.3"); // add boiler - EMSESP::add_device(0x08, 84, version, EMSdevice::Brand::BUDERUS); + add_device(0x08, 84); - // add Controller - BC10 GB142 - but using the same device_id to see what happens - EMSESP::add_device(0x09, 84, version, EMSdevice::Brand::BUDERUS); + // add Controller - BC10 GB142 - but using the same product_id to see what happens + add_device(0x09, 84); // simulate getting version information back from an unknown device // note there is no brand (byte 9) @@ -184,11 +178,15 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { } if (command == "unknown2") { + shell.printfln(F("Testing unknown2...")); + // simulate getting version information back from an unknown device rx_telegram({0x09, 0x0B, 0x02, 0x00, 0x5A, 0x01, 0x02}); // product id is 90 which doesn't exist } if (command == "gateway") { + shell.printfln(F("Testing Gateway...")); + // add 0x48 KM200, via a version command rx_telegram({0x48, 0x0B, 0x02, 0x00, 0xBD, 0x04, 0x06, 00, 00, 00, 00, 00, 00, 00}); @@ -197,8 +195,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { rx_telegram({0x08, 0x00, 0x07, 0x00, 0x09, 01, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00, 00}); // add thermostat - Thermostat: RC300/RC310/Moduline 3000/CW400/Sense II (DeviceID:0x10, ProductID:158, Version:03.03) ** master device ** - std::string version("01.03"); - EMSESP::add_device(0x10, 158, version, EMSdevice::Brand::BUDERUS); + add_device(0x10, 158); // Nefit Trendline // simulate incoming telegram // Thermostat(0x10) -> 48(0x48), ?(0x26B), data: 6B 08 4F 00 00 00 02 00 00 00 02 00 03 00 03 00 03 @@ -208,9 +205,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { if (command == "web") { shell.printfln(F("Testing Web...")); - std::string version("1.2.3"); - EMSESP::add_device(0x08, 123, version, EMSdevice::Brand::BUDERUS); // Nefit Trendline - EMSESP::add_device(0x18, 157, version, EMSdevice::Brand::BOSCH); // Bosch CR100 - https://github.com/proddy/EMS-ESP/issues/355 + add_device(0x08, 123); // Nefit Trendline + add_device(0x18, 157); // Bosch CR100 // add some data // Boiler -> Me, UBAMonitorFast(0x18), telegram: 08 00 18 00 00 02 5A 73 3D 0A 10 65 40 02 1A 80 00 01 E1 01 76 0E 3D 48 00 C9 44 02 00 (#data=25) @@ -238,13 +234,23 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { shell.println(); } + if (command == "boiler") { + shell.printfln(F("Testing boiler...")); + + add_device(0x08, 123); // Nefit Trendline + + // UBAuptime + uart_telegram({0x08, 0x0B, 0x14, 00, 0x3C, 0x1F, 0xAC, 0x70}); + + shell.invoke_command("show"); + shell.invoke_command("call boiler info"); + } + if (command == "general") { - shell.printfln(F("Testing adding a boiler & thermostat...")); + shell.printfln(F("Testing adding a general boiler & thermostat...")); - std::string version("1.2.3"); - - EMSESP::add_device(0x08, 123, version, EMSdevice::Brand::BUDERUS); // Nefit Trendline - EMSESP::add_device(0x18, 157, version, EMSdevice::Brand::BOSCH); // Bosch CR100 - https://github.com/proddy/EMS-ESP/issues/355 + add_device(0x08, 123); // Nefit Trendline + // add_device(0x18, 157); // Bosch CR100 // add some data // Boiler -> Me, UBAMonitorFast(0x18), telegram: 08 00 18 00 00 02 5A 73 3D 0A 10 65 40 02 1A 80 00 01 E1 01 76 0E 3D 48 00 C9 44 02 00 (#data=25) @@ -269,20 +275,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { if (command == "fr120") { shell.printfln(F("Testing adding a thermostat FR120...")); - // add_device(0x10, 165, version, EMSdevice::Brand::BUDERUS); - // add_device(0x17, 125, version, EMSdevice::Brand::BUDERUS); // test unknown class test - // add_device(0x17, 93, version, EMSdevice::Brand::BUDERUS); - // add_device(0x17, 254, version, EMSdevice::Brand::BUDERUS); // test unknown product_id - - // EMSESP::add_device(0x18, 157, version, EMSdevice::Brand::BOSCH); // Bosch CR100 - https://github.com/proddy/EMS-ESP/issues/355 - - std::string version("1.2.3"); - - // add a boiler - // EMSESP::add_device(0x08, 123, version, EMSdevice::Brand::BUDERUS); // Nefit Trendline - // add a thermostat - EMSESP::add_device(0x10, 191, version, EMSdevice::Brand::JUNKERS); // FR120 + add_device(0x10, 191); // FR120 // HC1 uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24, @@ -295,20 +289,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { if (command == "thermostat") { shell.printfln(F("Testing adding a thermostat FW120...")); - // add_device(0x10, 165, version, EMSdevice::Brand::BUDERUS); - // add_device(0x17, 125, version, EMSdevice::Brand::BUDERUS); // test unknown class test - // add_device(0x17, 93, version, EMSdevice::Brand::BUDERUS); - // add_device(0x17, 254, version, EMSdevice::Brand::BUDERUS); // test unknown product_id - - // EMSESP::add_device(0x18, 157, version, EMSdevice::Brand::BOSCH); // Bosch CR100 - https://github.com/proddy/EMS-ESP/issues/355 - - std::string version("1.2.3"); - - // add a boiler - // EMSESP::add_device(0x08, 123, version, EMSdevice::Brand::BUDERUS); // Nefit Trendline - // add a thermostat - EMSESP::add_device(0x10, 192, version, EMSdevice::Brand::JUNKERS); // FW120 + add_device(0x10, 192); // FW120 // HC1 uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24, @@ -331,13 +313,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { if (command == "tc100") { shell.printfln(F("Testing adding a TC100 thermostat to the EMS bus...")); - std::string version("02.21"); - - // add a boiler - // EMSESP::add_device(0x08, 123, version, EMSdevice::Brand::BUDERUS); // Nefit Trendline - // add a thermostat - EMSESP::add_device(0x18, 202, version, EMSdevice::Brand::BOSCH); // Bosch TC100 - https://github.com/proddy/EMS-ESP/issues/474 + add_device(0x18, 202); // Bosch TC100 - https://github.com/proddy/EMS-ESP/issues/474 // 0x0A uart_telegram({0x98, 0x0B, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -349,8 +326,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); - std::string version("1.2.3"); - EMSESP::add_device(0x30, 163, version, EMSdevice::Brand::BUDERUS); // SM100 + add_device(0x30, 163); // SM100 // SM100Monitor - type 0x0362 EMS+ - for SM100 and SM200 // B0 0B FF 00 02 62 00 44 02 7A 80 00 80 00 80 00 80 00 80 00 80 00 00 7C 80 00 80 00 80 00 80 @@ -377,19 +353,19 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); - std::string version("1.2.3"); - // add heatpump - EMSESP::add_device(0x38, 200, version, EMSdevice::Brand::BUDERUS); // Enviline module + add_device(0x38, 200); // Enviline module // add a thermostat - EMSESP::add_device(0x10, 192, version, EMSdevice::Brand::JUNKERS); // FW120 + add_device(0x10, 192); // FW120 + uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24, 0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03}); // HC1 uart_telegram("38 0B FF 00 03 7B 0C 34 00 74"); shell.invoke_command("call"); shell.invoke_command("call heatpump info"); + EMSESP::show_device_values(shell); } @@ -398,8 +374,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); - std::string version("1.2.3"); - EMSESP::add_device(0x30, 164, version, EMSdevice::Brand::BUDERUS); // SM200 + add_device(0x30, 164); // SM200 // SM100Monitor - type 0x0362 EMS+ - for SM100 and SM200 // B0 0B FF 00 02 62 00 44 02 7A 80 00 80 00 80 00 80 00 80 00 80 00 00 7C 80 00 80 00 80 00 80 @@ -433,13 +408,11 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); - std::string version("1.2.3"); - EMSESP::add_device(0x10, 158, version, EMSdevice::Brand::BUDERUS); // RC300 - EMSESP::add_device(0x48, 189, version, EMSdevice::Brand::BUDERUS); // KM200 + add_device(0x10, 158); // RC300 + add_device(0x48, 189); // KM200 // see https://github.com/proddy/EMS-ESP/issues/390 - /* uart_telegram_withCRC("90 48 FF 04 01 A6 5C"); uart_telegram_withCRC("90 48 FF 00 01 A6 4C"); uart_telegram_withCRC("90 48 FF 08 01 A7 6D"); @@ -477,7 +450,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { uart_telegram_withCRC("C8 90 FF 00 02 01 A6 D0"); // uart_telegram_withCRC("10 00 FF 00 01 A5 00 D7 21 00 00 00 00 30 01 84 01 01 03 01 84 01 F1 00 00 11 01 00 08 63 00"); - */ uart_telegram_withCRC("C8 90 F7 02 01 FF 01 A6 BA"); @@ -498,8 +470,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_HT3); // switch to junkers - std::string version("1.2.3"); - EMSESP::add_device(0x18, 157, version, EMSdevice::Brand::BOSCH); // Bosch CR100 - https://github.com/proddy/EMS-ESP/issues/355 + add_device(0x18, 157); // Bosch CR100 - https://github.com/proddy/EMS-ESP/issues/355 // RCPLUSStatusMessage_HC1(0x01A5) // 98 00 FF 00 01 A5 00 CF 21 2E 00 00 2E 24 03 25 03 03 01 03 25 00 C8 00 00 11 01 03 (no CRC) @@ -669,8 +640,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { shell.printfln(F("Testing Commands...")); // add a thermostat with 3 HCs - std::string version("1.2.3"); - EMSESP::add_device(0x10, 192, version, EMSdevice::Brand::JUNKERS); // FW120 + add_device(0x10, 192); // FW120 + uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24, 0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03}); // HC1 uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x70, 0x00, 0xCF, 0x22, 0x2F, 0x10, 0x00, 0x2E, 0x24, @@ -711,12 +682,10 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { }); // add a boiler - // question: do we need to set the mask? - std::string version("1.2.3"); - EMSESP::add_device(0x08, 123, version, EMSdevice::Brand::BUDERUS); // Nefit Trendline + add_device(0x08, 123); // Nefit Trendline // add a thermostat - EMSESP::add_device(0x18, 157, version, EMSdevice::Brand::BOSCH); // Bosch CR100 - https://github.com/proddy/EMS-ESP/issues/355 + add_device(0x18, 157); // Bosch CR100 - https://github.com/proddy/EMS-ESP/issues/355 // RCPLUSStatusMessage_HC1(0x01A5) - HC1 uart_telegram({0x98, 0x00, 0xFF, 0x00, 0x01, 0xA5, 0x00, 0xCF, 0x21, 0x2E, 0x00, 0x00, 0x2E, 0x24, @@ -791,23 +760,31 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { } if (command == "rx2") { + shell.printfln(F("Testing rx2...")); + uart_telegram({0x1B, 0x5B, 0xFD, 0x2D, 0x9E, 0x3A, 0xB6, 0xE5, 0x02, 0x20, 0x33, 0x30, 0x32, 0x3A, 0x20, 0x5B, 0x73, 0xFF, 0xFF, 0xCB, 0xDF, 0xB7, 0xA7, 0xB5, 0x67, 0x77, 0x77, 0xE4, 0xFF, 0xFD, 0x77, 0xFF}); } // https://github.com/proddy/EMS-ESP/issues/380#issuecomment-633663007 if (command == "rx3") { + shell.printfln(F("Testing rx3...")); + uart_telegram({0x21, 0x0B, 0xFF, 0x00}); } // testing the UART tx command, without a queue if (command == "tx2") { + shell.printfln(F("Testing tx2...")); + uint8_t t[] = {0x0B, 0x88, 0x18, 0x00, 0x20, 0xD4}; // including CRC EMSuart::transmit(t, sizeof(t)); } // send read request with offset if (command == "offset") { + shell.printfln(F("Testing offset...")); + // send_read_request(0x18, 0x08); EMSESP::txservice_.read_request(0x18, 0x08, 27); // no offset } @@ -824,14 +801,13 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { }); EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); - std::string version("1.2.3"); // add controller - EMSESP::add_device(0x09, 114, version, EMSdevice::Brand::BUDERUS); + add_device(0x09, 114); - EMSESP::add_device(0x28, 160, version, EMSdevice::Brand::BUDERUS); // MM100, WWC - EMSESP::add_device(0x29, 161, version, EMSdevice::Brand::BUDERUS); // MM200, WWC - EMSESP::add_device(0x20, 160, version, EMSdevice::Brand::BOSCH); // MM100 + add_device(0x28, 160); // MM100, WWC + add_device(0x29, 161); // MM200, WWC + add_device(0x20, 160); // MM100 // WWC1 on 0x29 uart_telegram({0xA9, 0x00, 0xFF, 0x00, 0x02, 0x32, 0x02, 0x6C, 0x00, 0x3C, 0x00, 0x3C, 0x3C, 0x46, 0x02, 0x03, 0x03, 0x00, 0x3C}); @@ -849,9 +825,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { shell.invoke_command("show mqtt"); shell.invoke_command("call mixer"); } - - // finally dump to console - EMSESP::loop(); } // simulates a telegram in the Rx queue, but without the CRC which is added automatically @@ -878,7 +851,7 @@ void Test::uart_telegram(const std::vector & rx_data) { } data[i] = EMSESP::rxservice_.calculate_crc(data, i); EMSESP::incoming_telegram(data, i + 1); - EMSESP::rxservice_.loop(); + // EMSESP::rxservice_.loop(); } // takes raw string, assuming it contains the CRC. This is what is output from 'watch raw' @@ -916,7 +889,7 @@ void Test::uart_telegram_withCRC(const char * rx_data) { } EMSESP::incoming_telegram(data, count + 1); - EMSESP::rxservice_.loop(); + // EMSESP::rxservice_.loop(); } // takes raw string, adds CRC to end @@ -956,14 +929,14 @@ void Test::uart_telegram(const char * rx_data) { data[count + 1] = EMSESP::rxservice_.calculate_crc(data, count + 1); // add CRC EMSESP::incoming_telegram(data, count + 2); - EMSESP::rxservice_.loop(); + // EMSESP::rxservice_.loop(); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - - -#pragma GCC diagnostic pop +// Sends version telegram. Version is hardcoded to 1.0 +void Test::add_device(uint8_t device_id, uint8_t product_id) { + // Send version: 09 0B 02 00 PP V1 V2 + uart_telegram({device_id, EMSESP_DEFAULT_EMS_BUS_ID, EMSdevice::EMS_TYPE_VERSION, 0, product_id, 1, 0}); +} } // namespace emsesp diff --git a/src/test/test.h b/src/test/test.h index 470cdd62e..4dcb75e41 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -40,12 +40,13 @@ namespace emsesp { class Test { public: - static void run_test(uuid::console::Shell & shell, const std::string & command); // only for testing + static void run_test(uuid::console::Shell & shell, const std::string & command); static void dummy_mqtt_commands(const char * message); static void rx_telegram(const std::vector & data); static void uart_telegram(const std::vector & rx_data); static void uart_telegram(const char * rx_data); static void uart_telegram_withCRC(const char * rx_data); + static void add_device(uint8_t device_id, uint8_t product_id); }; } // namespace emsesp From 3ffa9ee5acc558f4115b5e4ff108818c2c3b842b Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 14 Nov 2020 00:08:05 +0100 Subject: [PATCH 5/6] move device unique_id count into constructor --- src/emsdevice.h | 3 ++- src/emsesp.cpp | 11 ++++++----- src/emsesp.h | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/emsdevice.h b/src/emsdevice.h index 81ac08c44..a4a9fe2a1 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -43,6 +43,7 @@ class EMSdevice { , name_(name) , flags_(flags) , brand_(brand) { + unique_id_++; } virtual ~EMSdevice() = default; // destructor of base class must always be virtual because it's a polymorphic class @@ -270,7 +271,7 @@ class EMSdevice { static constexpr uint8_t EMS_DEVICE_FLAG_JUNKERS_2 = (1 << 6); // 6th bit set if older models, like FR120, FR100 private: - uint8_t unique_id_; + uint8_t unique_id_ = 0; uint8_t device_type_ = DeviceType::SYSTEM; uint8_t device_id_ = 0; uint8_t product_id_ = 0; diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 91b30df71..ad6273945 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -63,7 +63,6 @@ bool EMSESP::read_next_ = false; uint16_t EMSESP::publish_id_ = 0; bool EMSESP::tap_water_active_ = false; // for when Boiler states we having running warm water. used in Shower() uint32_t EMSESP::last_fetch_ = 0; -uint8_t EMSESP::unique_id_count_ = 0; // for a specific EMS device go and request data values // or if device_id is 0 it will fetch from all our known and active devices @@ -722,17 +721,19 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, std:: return false; // not found } - std::string name = uuid::read_flash_string(device_p->name); - emsdevices.push_back(EMSFactory::add(device_p->device_type, device_id, device_p->product_id, version, name, device_p->flags, brand)); - emsdevices.back()->unique_id(++unique_id_count_); + auto name = uuid::read_flash_string(device_p->name); + auto device_type = device_p->device_type; + auto flags = device_p->flags; LOG_DEBUG(F("Adding new device %s (device ID 0x%02X, product ID %d, version %s)"), name.c_str(), device_id, product_id, version.c_str()); + emsdevices.push_back(EMSFactory::add(device_type, device_id, product_id, version, name, flags, brand)); + fetch_device_values(device_id); // go and fetch its data // add info command, but not for all devices - uint8_t device_type = device_p->device_type; if ((device_type == DeviceType::CONNECT) || (device_type == DeviceType::CONTROLLER) || (device_type == DeviceType::GATEWAY)) { return true; } + Command::add_with_json(device_type, F_(info), [device_type](const char * value, const int8_t id, JsonObject & json) { return command_info(device_type, json); }); diff --git a/src/emsesp.h b/src/emsesp.h index 0fd6d976a..5b6e95052 100644 --- a/src/emsesp.h +++ b/src/emsesp.h @@ -206,7 +206,6 @@ class EMSESP { static bool read_next_; static uint16_t publish_id_; static bool tap_water_active_; - static uint8_t unique_id_count_; }; } // namespace emsesp From 937998d9e30ec2b48a4b3a62d7c8cb77f00ce228 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 14 Nov 2020 00:10:40 +0100 Subject: [PATCH 6/6] 2.1.1b2 --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 4616c4e4d..94e8574ec 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "2.1.1b1" +#define EMSESP_APP_VERSION "2.1.1b2"