From 932cb48fa2efbdf34e8100526820812882ba4f15 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 13:34:04 +0200 Subject: [PATCH 01/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 348b2e4..8e450f0 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -44,14 +44,14 @@ struct Flowiq2200: Driver if (tpl_ci_field == 0x78) { ret_val = this->get_0413(telegram); } - // else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - // uint32_t usage{0}; - // uint8_t i = 46; - // usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | - // ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - // ret_val = usage / 1000.0; - // ESP_LOGVV(TAG, "Found total_water with '%d'->'%f'", usage, ret_val.value()); - // } + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + uint32_t usage{0}; + uint8_t i = 57; + usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | + ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = usage / 1000.0; + ESP_LOGVV(TAG, "Found total_water with '%d'->'%f'", usage, ret_val.value()); + } return ret_val; }; From f72b6a430da3bbf35d57a9f35275fe21b61c7d30 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 13:44:34 +0200 Subject: [PATCH 02/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 8e450f0..9ab5c66 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -45,8 +45,9 @@ struct Flowiq2200: Driver ret_val = this->get_0413(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + ESP_LOGVV(TAG, "Found compressed frame"); uint32_t usage{0}; - uint8_t i = 57; + uint8_t i = 28; usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); ret_val = usage / 1000.0; From 85aba316d6e37615f4b1c0c892c6f10fd279753e Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 13:52:16 +0200 Subject: [PATCH 03/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 9ab5c66..e8f4dd5 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -47,7 +47,7 @@ struct Flowiq2200: Driver else if ((tpl_ci_field == 0x79) && (l_field > 49)) { ESP_LOGVV(TAG, "Found compressed frame"); uint32_t usage{0}; - uint8_t i = 28; + uint8_t i = 29; usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); ret_val = usage / 1000.0; From 0ed0abde0219f73dcd32d96dc53c00788ddcd2e6 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:14:14 +0200 Subject: [PATCH 04/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index e8f4dd5..83b3b58 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -63,14 +63,15 @@ struct Flowiq2200: Driver if (tpl_ci_field == 0x78) { ret_val = this->get_4413(telegram); } - // else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + ESP_LOGVV(TAG, "Found compressed frame"); // uint32_t usage{0}; // uint8_t i = 28; // usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | // ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); // ret_val = usage / 1000.0; // ESP_LOGVV(TAG, "Found target_water with '%d'->'%f'", usage, ret_val.value()); - // } + } return ret_val; }; @@ -81,7 +82,8 @@ struct Flowiq2200: Driver if (tpl_ci_field == 0x78) { ret_val = this->get_04FF23(telegram); } - // else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + ESP_LOGVV(TAG, "Found compressed frame"); // uint32_t status{0}; // uint8_t i = 24; // status = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | @@ -99,13 +101,14 @@ struct Flowiq2200: Driver if (tpl_ci_field == 0x78) { ret_val = this->get_023B(telegram); } - // else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + ESP_LOGVV(TAG, "Found compressed frame"); // uint32_t flow{0}; // uint8_t i = 44; // flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); // ret_val = (double)flow; // ESP_LOGVV(TAG, "Found volume_flow with '%d'->'%f'", flow, ret_val.value()); - // } + } return ret_val; }; @@ -116,13 +119,14 @@ struct Flowiq2200: Driver if (tpl_ci_field == 0x78) { ret_val = this->get_523B(telegram); } - // else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + ESP_LOGVV(TAG, "Found compressed frame"); // uint32_t flow{0}; // uint8_t i = 32; // flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); // ret_val = (double)flow; // ESP_LOGVV(TAG, "Found max_flow with '%d'->'%f'", flow, ret_val.value()); - // } + } return ret_val; }; From 5b2b26d032e017313a82a97d418277668f75e120 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:22:53 +0200 Subject: [PATCH 05/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 62 ++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 83b3b58..62e2c1a 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -44,10 +44,10 @@ struct Flowiq2200: Driver if (tpl_ci_field == 0x78) { ret_val = this->get_0413(telegram); } - else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGVV(TAG, "Found compressed frame"); + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + uint32_t usage{0}; - uint8_t i = 29; + uint8_t i = 28; usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); ret_val = usage / 1000.0; @@ -64,13 +64,13 @@ struct Flowiq2200: Driver ret_val = this->get_4413(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGVV(TAG, "Found compressed frame"); - // uint32_t usage{0}; - // uint8_t i = 28; - // usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | - // ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - // ret_val = usage / 1000.0; - // ESP_LOGVV(TAG, "Found target_water with '%d'->'%f'", usage, ret_val.value()); + ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t usage{0}; + uint8_t i = 28; + usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | + ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = usage / 1000.0; + ESP_LOGVV(TAG, "Found target_water with '%d'->'%f'", usage, ret_val.value()); } return ret_val; }; @@ -83,14 +83,14 @@ struct Flowiq2200: Driver ret_val = this->get_04FF23(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGVV(TAG, "Found compressed frame"); - // uint32_t status{0}; - // uint8_t i = 24; - // status = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | - // ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - // ret_val = (double)status; - // ESP_LOGVV(TAG, "Found status with '%08X'", status); - // } + ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t status{0}; + uint8_t i = 24; + status = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | + ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)status; + ESP_LOGVV(TAG, "Found status with '%08X'", status); + } return ret_val; }; @@ -101,13 +101,13 @@ struct Flowiq2200: Driver if (tpl_ci_field == 0x78) { ret_val = this->get_023B(telegram); } - else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGVV(TAG, "Found compressed frame"); - // uint32_t flow{0}; - // uint8_t i = 44; - // flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - // ret_val = (double)flow; - // ESP_LOGVV(TAG, "Found volume_flow with '%d'->'%f'", flow, ret_val.value()); + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t flow{0}; + uint8_t i = 44; + flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)flow; + ESP_LOGVV(TAG, "Found volume_flow with '%d'->'%f'", flow, ret_val.value()); } return ret_val; }; @@ -120,12 +120,12 @@ struct Flowiq2200: Driver ret_val = this->get_523B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGVV(TAG, "Found compressed frame"); - // uint32_t flow{0}; - // uint8_t i = 32; - // flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - // ret_val = (double)flow; - // ESP_LOGVV(TAG, "Found max_flow with '%d'->'%f'", flow, ret_val.value()); + ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t flow{0}; + uint8_t i = 32; + flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)flow; + ESP_LOGVV(TAG, "Found max_flow with '%d'->'%f'", flow, ret_val.value()); } return ret_val; }; From b851253aef488c8914f9fc2b02868c5be3b28489 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 16:07:27 +0200 Subject: [PATCH 06/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 62e2c1a..949f18a 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -66,7 +66,7 @@ struct Flowiq2200: Driver else if ((tpl_ci_field == 0x79) && (l_field > 49)) { ESP_LOGD(TAG, "Received frame is compressed"); uint32_t usage{0}; - uint8_t i = 28; + uint8_t i = 34; usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); ret_val = usage / 1000.0; @@ -85,7 +85,7 @@ struct Flowiq2200: Driver else if ((tpl_ci_field == 0x79) && (l_field > 49)) { ESP_LOGD(TAG, "Received frame is compressed"); uint32_t status{0}; - uint8_t i = 24; + uint8_t i = 22; status = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); ret_val = (double)status; From 6b5383c8856a85518da4d63e7f911d4d606aa3d9 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 20:04:22 +0200 Subject: [PATCH 07/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 949f18a..a8b896d 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -66,7 +66,7 @@ struct Flowiq2200: Driver else if ((tpl_ci_field == 0x79) && (l_field > 49)) { ESP_LOGD(TAG, "Received frame is compressed"); uint32_t usage{0}; - uint8_t i = 34; + uint8_t i = 32; usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); ret_val = usage / 1000.0; From d59198e45e24363d90dc9ac9d7e3fee9ebbb8182 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 20:13:07 +0200 Subject: [PATCH 08/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index a8b896d..8c7b821 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -85,7 +85,7 @@ struct Flowiq2200: Driver else if ((tpl_ci_field == 0x79) && (l_field > 49)) { ESP_LOGD(TAG, "Received frame is compressed"); uint32_t status{0}; - uint8_t i = 22; + uint8_t i = 24; status = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); ret_val = (double)status; @@ -104,7 +104,7 @@ struct Flowiq2200: Driver else if ((tpl_ci_field == 0x79) && (l_field > 49)) { ESP_LOGD(TAG, "Received frame is compressed"); uint32_t flow{0}; - uint8_t i = 44; + uint8_t i = 22; flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); ret_val = (double)flow; ESP_LOGVV(TAG, "Found volume_flow with '%d'->'%f'", flow, ret_val.value()); @@ -122,7 +122,7 @@ struct Flowiq2200: Driver else if ((tpl_ci_field == 0x79) && (l_field > 49)) { ESP_LOGD(TAG, "Received frame is compressed"); uint32_t flow{0}; - uint8_t i = 32; + uint8_t i = 40; flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); ret_val = (double)flow; ESP_LOGVV(TAG, "Found max_flow with '%d'->'%f'", flow, ret_val.value()); From 2461812eb433a6307539df4fbadd9e2901df0feb Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 20:24:07 +0200 Subject: [PATCH 09/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 55 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 8c7b821..b0c4df5 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -20,7 +20,10 @@ struct Flowiq2200: Driver add_to_map(ret_val, "target_water_m3", this->get_target_water_m3(telegram)); add_to_map(ret_val, "status", this->get_status(telegram)); add_to_map(ret_val, "volume_flow_lh", this->get_volume_flow_lh(telegram)); + add_to_map(ret_val, "min_flow_lh", this->get_min_flow_lh(telegram)); add_to_map(ret_val, "max_flow_lh", this->get_max_flow_lh(telegram)); + add_to_map(ret_val, "min_flow_temperature_c", this->get_min_flow_temperature_c(telegram)); + add_to_map(ret_val, "max_flow_temperature_c", this->get_max_flow_temperature_c(telegram)); if (ret_val.size() > 0) { return ret_val; @@ -112,6 +115,23 @@ struct Flowiq2200: Driver return ret_val; }; + esphome::optional get_min_flow_lh(std::vector &telegram) { + esphome::optional ret_val{}; + uint8_t l_field = telegram[0]; + uint8_t tpl_ci_field = telegram[19]; + if (tpl_ci_field == 0x78) { + ret_val = this->get_523B(telegram); + } + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t flow{0}; + uint8_t i = 27; + flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)flow; + ESP_LOGVV(TAG, "Found min_flow with '%d'->'%f'", flow, ret_val.value()); + } + return ret_val; + }; esphome::optional get_max_flow_lh(std::vector &telegram) { esphome::optional ret_val{}; uint8_t l_field = telegram[0]; @@ -129,5 +149,38 @@ struct Flowiq2200: Driver } return ret_val; }; - + esphome::optional get_min_flow_temperature_c(std::vector &telegram) { + esphome::optional ret_val{}; + uint8_t l_field = telegram[0]; + uint8_t tpl_ci_field = telegram[19]; + if (tpl_ci_field == 0x78) { + ret_val = this->get_523B(telegram); + } + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t flow{0}; + uint8_t i = 34; + flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)flow; + ESP_LOGVV(TAG, "Found min_flow_temperature_c with '%d'->'%f'", flow, ret_val.value()); + } + return ret_val; + }; + esphome::optional get_max_flow_temperature_c(std::vector &telegram) { + esphome::optional ret_val{}; + uint8_t l_field = telegram[0]; + uint8_t tpl_ci_field = telegram[19]; + if (tpl_ci_field == 0x78) { + ret_val = this->get_523B(telegram); + } + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t flow{0}; + uint8_t i = 36; + flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)flow; + ESP_LOGVV(TAG, "Found max_flow_temperature_c with '%d'->'%f'", flow, ret_val.value()); + } + return ret_val; + }; }; From 21b0a9216e1d641a1b06f92739c42f5ba687c819 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 20:56:18 +0200 Subject: [PATCH 10/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index b0c4df5..1341389 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -154,7 +154,7 @@ struct Flowiq2200: Driver uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; if (tpl_ci_field == 0x78) { - ret_val = this->get_523B(telegram); + ret_val = this->get_615B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { ESP_LOGD(TAG, "Received frame is compressed"); @@ -171,7 +171,7 @@ struct Flowiq2200: Driver uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; if (tpl_ci_field == 0x78) { - ret_val = this->get_523B(telegram); + ret_val = this->get_615B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { ESP_LOGD(TAG, "Received frame is compressed"); From 9c05062262d10ba9124949a5e3450be942887bd5 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 21:11:28 +0200 Subject: [PATCH 11/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 1341389..f02e90d 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -4,7 +4,7 @@ */ #pragma once - + #include "driver.h" #include From 22c72263576e2a52b3c2f8afff1565d0ed44cdad Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Fri, 23 Aug 2024 21:27:13 +0200 Subject: [PATCH 12/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index f02e90d..5c28d64 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -67,7 +67,7 @@ struct Flowiq2200: Driver ret_val = this->get_4413(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t usage{0}; uint8_t i = 32; usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | @@ -86,7 +86,7 @@ struct Flowiq2200: Driver ret_val = this->get_04FF23(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t status{0}; uint8_t i = 24; status = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | @@ -105,7 +105,7 @@ struct Flowiq2200: Driver ret_val = this->get_023B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t flow{0}; uint8_t i = 22; flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); @@ -123,7 +123,7 @@ struct Flowiq2200: Driver ret_val = this->get_523B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t flow{0}; uint8_t i = 27; flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); @@ -140,7 +140,7 @@ struct Flowiq2200: Driver ret_val = this->get_523B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t flow{0}; uint8_t i = 40; flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); @@ -157,7 +157,7 @@ struct Flowiq2200: Driver ret_val = this->get_615B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t flow{0}; uint8_t i = 34; flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); @@ -174,7 +174,7 @@ struct Flowiq2200: Driver ret_val = this->get_615B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGD(TAG, "Received frame is compressed"); + uint32_t flow{0}; uint8_t i = 36; flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); From ea239bb53374d5b38e3432bdcee770b40f13506e Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Sat, 24 Aug 2024 20:40:28 +0200 Subject: [PATCH 13/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 5c28d64..b4bdd79 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -44,11 +44,12 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; + uint16_t signature = ((uint16_t)telegram[20] << 8) | telegram[21]; if (tpl_ci_field == 0x78) { ret_val = this->get_0413(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - + ESP_LOGD(TAG, "Signature of message is: '%H'", signature); uint32_t usage{0}; uint8_t i = 28; usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | From cfd7a9f3f28333794a08c528326290f7f6b9af41 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Sat, 24 Aug 2024 20:44:15 +0200 Subject: [PATCH 14/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index b4bdd79..72258b8 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -49,7 +49,7 @@ struct Flowiq2200: Driver ret_val = this->get_0413(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGD(TAG, "Signature of message is: '%H'", signature); + ESP_LOGD(TAG, "Signature of message is: '%X'", signature); uint32_t usage{0}; uint8_t i = 28; usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | From 235a011dd8271d04403f8cd2f9ef3565ca3be877 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Sat, 24 Aug 2024 20:57:40 +0200 Subject: [PATCH 15/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 72258b8..7f8a0d0 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -44,18 +44,28 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; - uint16_t signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + uint16_t signature; + if ((tpl_ci_field == 0x79) && (l_field > 49)) { + signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); + } + else + { + signature = 0; + } if (tpl_ci_field == 0x78) { ret_val = this->get_0413(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - ESP_LOGD(TAG, "Signature of message is: '%X'", signature); - uint32_t usage{0}; - uint8_t i = 28; - usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | - ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - ret_val = usage / 1000.0; - ESP_LOGVV(TAG, "Found total_water with '%d'->'%f'", usage, ret_val.value()); + if (signature == 0xF3A9) { + ESP_LOGD(TAG, "Signature of message is: '%X'", signature); + uint32_t usage{0}; + uint8_t i = 28; + usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | + ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = usage / 1000.0; + ESP_LOGVV(TAG, "Found total_water with '%d'->'%f'", usage, ret_val.value()); + } } return ret_val; }; From f0c8226f5099ba8d8b468062595bd9517b9ea8b9 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Sat, 24 Aug 2024 21:04:41 +0200 Subject: [PATCH 16/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 106 +++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 51 deletions(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 7f8a0d0..499d340 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -44,15 +44,12 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; - uint16_t signature; + uint16_t signature = 0; if ((tpl_ci_field == 0x79) && (l_field > 49)) { signature = ((uint16_t)telegram[20] << 8) | telegram[21]; ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); } - else - { - signature = 0; - } + if (tpl_ci_field == 0x78) { ret_val = this->get_0413(telegram); } @@ -77,14 +74,15 @@ struct Flowiq2200: Driver if (tpl_ci_field == 0x78) { ret_val = this->get_4413(telegram); } - else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - - uint32_t usage{0}; - uint8_t i = 32; - usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | - ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - ret_val = usage / 1000.0; - ESP_LOGVV(TAG, "Found target_water with '%d'->'%f'", usage, ret_val.value()); + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + if (signature == 0xF3A9) { + uint32_t usage{0}; + uint8_t i = 32; + usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | + ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = usage / 1000.0; + ESP_LOGVV(TAG, "Found target_water with '%d'->'%f'", usage, ret_val.value()); + } } return ret_val; }; @@ -97,13 +95,14 @@ struct Flowiq2200: Driver ret_val = this->get_04FF23(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - - uint32_t status{0}; - uint8_t i = 24; - status = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | - ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - ret_val = (double)status; - ESP_LOGVV(TAG, "Found status with '%08X'", status); + if (signature == 0xF3A9) { + uint32_t status{0}; + uint8_t i = 24; + status = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | + ((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)status; + ESP_LOGVV(TAG, "Found status with '%08X'", status); + } } return ret_val; }; @@ -115,13 +114,14 @@ struct Flowiq2200: Driver if (tpl_ci_field == 0x78) { ret_val = this->get_023B(telegram); } - else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - - uint32_t flow{0}; - uint8_t i = 22; - flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - ret_val = (double)flow; - ESP_LOGVV(TAG, "Found volume_flow with '%d'->'%f'", flow, ret_val.value()); + else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + if (signature == 0xF3A9) { + uint32_t flow{0}; + uint8_t i = 22; + flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)flow; + ESP_LOGVV(TAG, "Found volume_flow with '%d'->'%f'", flow, ret_val.value()); + } } return ret_val; }; @@ -134,12 +134,13 @@ struct Flowiq2200: Driver ret_val = this->get_523B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - - uint32_t flow{0}; - uint8_t i = 27; - flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - ret_val = (double)flow; - ESP_LOGVV(TAG, "Found min_flow with '%d'->'%f'", flow, ret_val.value()); + if (signature == 0xF3A9) { + uint32_t flow{0}; + uint8_t i = 27; + flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)flow; + ESP_LOGVV(TAG, "Found min_flow with '%d'->'%f'", flow, ret_val.value()); + } } return ret_val; }; @@ -151,12 +152,13 @@ struct Flowiq2200: Driver ret_val = this->get_523B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - - uint32_t flow{0}; - uint8_t i = 40; - flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - ret_val = (double)flow; - ESP_LOGVV(TAG, "Found max_flow with '%d'->'%f'", flow, ret_val.value()); + if (signature == 0xF3A9) { + uint32_t flow{0}; + uint8_t i = 40; + flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)flow; + ESP_LOGVV(TAG, "Found max_flow with '%d'->'%f'", flow, ret_val.value()); + } } return ret_val; }; @@ -168,12 +170,13 @@ struct Flowiq2200: Driver ret_val = this->get_615B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - - uint32_t flow{0}; - uint8_t i = 34; - flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - ret_val = (double)flow; - ESP_LOGVV(TAG, "Found min_flow_temperature_c with '%d'->'%f'", flow, ret_val.value()); + if (signature == 0xF3A9) { + uint32_t flow{0}; + uint8_t i = 34; + flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)flow; + ESP_LOGVV(TAG, "Found min_flow_temperature_c with '%d'->'%f'", flow, ret_val.value()); + } } return ret_val; }; @@ -185,12 +188,13 @@ struct Flowiq2200: Driver ret_val = this->get_615B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - - uint32_t flow{0}; - uint8_t i = 36; - flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - ret_val = (double)flow; - ESP_LOGVV(TAG, "Found max_flow_temperature_c with '%d'->'%f'", flow, ret_val.value()); + if (signature == 0xF3A9) { + uint32_t flow{0}; + uint8_t i = 36; + flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); + ret_val = (double)flow; + ESP_LOGVV(TAG, "Found max_flow_temperature_c with '%d'->'%f'", flow, ret_val.value()); + } } return ret_val; }; From 55454396faf274fd65cc73b9ddeac663cfc838d2 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Sat, 24 Aug 2024 21:05:21 +0200 Subject: [PATCH 17/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 1 - 1 file changed, 1 deletion(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 499d340..af7572d 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -55,7 +55,6 @@ struct Flowiq2200: Driver } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { if (signature == 0xF3A9) { - ESP_LOGD(TAG, "Signature of message is: '%X'", signature); uint32_t usage{0}; uint8_t i = 28; usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) | From 2044b9b7a50d3673cfd741f6ef5a749fd408dd27 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Sat, 24 Aug 2024 21:08:14 +0200 Subject: [PATCH 18/20] Update driver_flowiq2200.h --- driver_flowiq2200.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index af7572d..6e81e73 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -70,6 +70,11 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; + uint16_t signature = 0; + if ((tpl_ci_field == 0x79) && (l_field > 49)) { + signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); + } if (tpl_ci_field == 0x78) { ret_val = this->get_4413(telegram); } @@ -90,6 +95,11 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; + uint16_t signature = 0; + if ((tpl_ci_field == 0x79) && (l_field > 49)) { + signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); + } if (tpl_ci_field == 0x78) { ret_val = this->get_04FF23(telegram); } @@ -110,6 +120,11 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; + uint16_t signature = 0; + if ((tpl_ci_field == 0x79) && (l_field > 49)) { + signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); + } if (tpl_ci_field == 0x78) { ret_val = this->get_023B(telegram); } @@ -129,6 +144,11 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; + uint16_t signature = 0; + if ((tpl_ci_field == 0x79) && (l_field > 49)) { + signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); + } if (tpl_ci_field == 0x78) { ret_val = this->get_523B(telegram); } @@ -147,6 +167,11 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; + uint16_t signature = 0; + if ((tpl_ci_field == 0x79) && (l_field > 49)) { + signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); + } if (tpl_ci_field == 0x78) { ret_val = this->get_523B(telegram); } @@ -165,6 +190,11 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; + uint16_t signature = 0; + if ((tpl_ci_field == 0x79) && (l_field > 49)) { + signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); + } if (tpl_ci_field == 0x78) { ret_val = this->get_615B(telegram); } @@ -183,6 +213,11 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; + uint16_t signature = 0; + if ((tpl_ci_field == 0x79) && (l_field > 49)) { + signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); + } if (tpl_ci_field == 0x78) { ret_val = this->get_615B(telegram); } From 66acb660809dcb6d6031c849880d32540f04d5a1 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Sat, 24 Aug 2024 21:27:57 +0200 Subject: [PATCH 19/20] Added support for compressed frames --- driver_flowiq2200.h | 53 +-------------------------------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 6e81e73..3390ac7 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -22,8 +22,6 @@ struct Flowiq2200: Driver add_to_map(ret_val, "volume_flow_lh", this->get_volume_flow_lh(telegram)); add_to_map(ret_val, "min_flow_lh", this->get_min_flow_lh(telegram)); add_to_map(ret_val, "max_flow_lh", this->get_max_flow_lh(telegram)); - add_to_map(ret_val, "min_flow_temperature_c", this->get_min_flow_temperature_c(telegram)); - add_to_map(ret_val, "max_flow_temperature_c", this->get_max_flow_temperature_c(telegram)); if (ret_val.size() > 0) { return ret_val; @@ -98,7 +96,6 @@ struct Flowiq2200: Driver uint16_t signature = 0; if ((tpl_ci_field == 0x79) && (l_field > 49)) { signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); } if (tpl_ci_field == 0x78) { ret_val = this->get_04FF23(telegram); @@ -123,7 +120,6 @@ struct Flowiq2200: Driver uint16_t signature = 0; if ((tpl_ci_field == 0x79) && (l_field > 49)) { signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); } if (tpl_ci_field == 0x78) { ret_val = this->get_023B(telegram); @@ -147,7 +143,6 @@ struct Flowiq2200: Driver uint16_t signature = 0; if ((tpl_ci_field == 0x79) && (l_field > 49)) { signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); } if (tpl_ci_field == 0x78) { ret_val = this->get_523B(telegram); @@ -170,7 +165,6 @@ struct Flowiq2200: Driver uint16_t signature = 0; if ((tpl_ci_field == 0x79) && (l_field > 49)) { signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); } if (tpl_ci_field == 0x78) { ret_val = this->get_523B(telegram); @@ -186,50 +180,5 @@ struct Flowiq2200: Driver } return ret_val; }; - esphome::optional get_min_flow_temperature_c(std::vector &telegram) { - esphome::optional ret_val{}; - uint8_t l_field = telegram[0]; - uint8_t tpl_ci_field = telegram[19]; - uint16_t signature = 0; - if ((tpl_ci_field == 0x79) && (l_field > 49)) { - signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); - } - if (tpl_ci_field == 0x78) { - ret_val = this->get_615B(telegram); - } - else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - if (signature == 0xF3A9) { - uint32_t flow{0}; - uint8_t i = 34; - flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - ret_val = (double)flow; - ESP_LOGVV(TAG, "Found min_flow_temperature_c with '%d'->'%f'", flow, ret_val.value()); - } - } - return ret_val; - }; - esphome::optional get_max_flow_temperature_c(std::vector &telegram) { - esphome::optional ret_val{}; - uint8_t l_field = telegram[0]; - uint8_t tpl_ci_field = telegram[19]; - uint16_t signature = 0; - if ((tpl_ci_field == 0x79) && (l_field > 49)) { - signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); - } - if (tpl_ci_field == 0x78) { - ret_val = this->get_615B(telegram); - } - else if ((tpl_ci_field == 0x79) && (l_field > 49)) { - if (signature == 0xF3A9) { - uint32_t flow{0}; - uint8_t i = 36; - flow = (((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0])); - ret_val = (double)flow; - ESP_LOGVV(TAG, "Found max_flow_temperature_c with '%d'->'%f'", flow, ret_val.value()); - } - } - return ret_val; - }; + }; From 77a030e0ae8be93390e210358906b3669e9cf858 Mon Sep 17 00:00:00 2001 From: anhorbc <60405237+anhorbc@users.noreply.github.com> Date: Tue, 27 Aug 2024 12:28:32 +0200 Subject: [PATCH 20/20] Update driver_flowiq2200.h Cleanup of code --- driver_flowiq2200.h | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/driver_flowiq2200.h b/driver_flowiq2200.h index 3390ac7..26fff91 100644 --- a/driver_flowiq2200.h +++ b/driver_flowiq2200.h @@ -42,16 +42,13 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; - uint16_t signature = 0; - if ((tpl_ci_field == 0x79) && (l_field > 49)) { - signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); - } if (tpl_ci_field == 0x78) { ret_val = this->get_0413(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + uint16_t signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); if (signature == 0xF3A9) { uint32_t usage{0}; uint8_t i = 28; @@ -68,15 +65,13 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; - uint16_t signature = 0; - if ((tpl_ci_field == 0x79) && (l_field > 49)) { - signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); - } + if (tpl_ci_field == 0x78) { ret_val = this->get_4413(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + uint16_t signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); if (signature == 0xF3A9) { uint32_t usage{0}; uint8_t i = 32; @@ -93,14 +88,13 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; - uint16_t signature = 0; - if ((tpl_ci_field == 0x79) && (l_field > 49)) { - signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - } + if (tpl_ci_field == 0x78) { ret_val = this->get_04FF23(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + uint16_t signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); if (signature == 0xF3A9) { uint32_t status{0}; uint8_t i = 24; @@ -117,14 +111,13 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; - uint16_t signature = 0; - if ((tpl_ci_field == 0x79) && (l_field > 49)) { - signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - } + if (tpl_ci_field == 0x78) { ret_val = this->get_023B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + uint16_t signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); if (signature == 0xF3A9) { uint32_t flow{0}; uint8_t i = 22; @@ -140,14 +133,13 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; - uint16_t signature = 0; - if ((tpl_ci_field == 0x79) && (l_field > 49)) { - signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - } + if (tpl_ci_field == 0x78) { ret_val = this->get_523B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + uint16_t signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); if (signature == 0xF3A9) { uint32_t flow{0}; uint8_t i = 27; @@ -162,14 +154,13 @@ struct Flowiq2200: Driver esphome::optional ret_val{}; uint8_t l_field = telegram[0]; uint8_t tpl_ci_field = telegram[19]; - uint16_t signature = 0; - if ((tpl_ci_field == 0x79) && (l_field > 49)) { - signature = ((uint16_t)telegram[20] << 8) | telegram[21]; - } + if (tpl_ci_field == 0x78) { ret_val = this->get_523B(telegram); } else if ((tpl_ci_field == 0x79) && (l_field > 49)) { + uint16_t signature = ((uint16_t)telegram[20] << 8) | telegram[21]; + ESP_LOGVV(TAG, "Signature of message is: '%X'", signature); if (signature == 0xF3A9) { uint32_t flow{0}; uint8_t i = 40;