From 346628f8ed8ef0563e0a578d881a3d4303f7183b Mon Sep 17 00:00:00 2001 From: wonsky007 <98755579+wonsky007@users.noreply.github.com> Date: Wed, 20 Dec 2023 11:41:25 +0100 Subject: [PATCH] Update driver.h Added get_0C09 for Hydrocal M4 --- driver.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/driver.h b/driver.h index c2326a7..5131b45 100755 --- a/driver.h +++ b/driver.h @@ -95,6 +95,27 @@ struct Driver return ret_val; }; + + esphome::optional get_0C09(std::vector &telegram) { + esphome::optional ret_val{}; + uint32_t usage = 0; + size_t i = 11; + uint32_t total_register = 0x0C09; + while (i < telegram.size()) { + uint32_t c = (((uint32_t)telegram[i+0] << 8) | ((uint32_t)telegram[i+1])); + if (c == total_register) { + i += 2; + usage = bcd_2_int(telegram, i, 4); + // in kWh + ret_val = usage / 3.6; + ESP_LOGVV(TAG, "Found register '0C09' with '%d'->'%f'", usage, ret_val.value()); + break; + } + i++; + } + return ret_val; + }; + esphome::optional get_0C0D(std::vector &telegram) { esphome::optional ret_val{}; uint32_t usage = 0;