From 943c18624c971a5285ecaddef4c2fe5ba3801bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Seux?= Date: Wed, 1 Nov 2023 16:07:22 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Prepare=20firmware=203.2.3+=20suppo?= =?UTF-8?q?rt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several topics have been renamed --- custom_components/aquarea/definitions.py | 9 +++++++- custom_components/aquarea/sensor.py | 27 ++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/custom_components/aquarea/definitions.py b/custom_components/aquarea/definitions.py index 36c9c8b..fa9c2b0 100644 --- a/custom_components/aquarea/definitions.py +++ b/custom_components/aquarea/definitions.py @@ -901,6 +901,7 @@ def build_sensors(mqtt_prefix: str) -> list[HeishaMonSensorEntityDescription]: heishamon_topic_id="TOP15", key=f"{mqtt_prefix}main/Heat_Power_Production", topics=[ + f"{mqtt_prefix}extra/Heat_Power_Production_Extra", # XTOP3, fw >= 3.2.3 f"{mqtt_prefix}extra/Heat_Power_Production", # XTOP3 f"{mqtt_prefix}main/Heat_Power_Production", f"{mqtt_prefix}main/Heat_Energy_Production", @@ -915,6 +916,7 @@ def build_sensors(mqtt_prefix: str) -> list[HeishaMonSensorEntityDescription]: heishamon_topic_id="TOP16", key=f"{mqtt_prefix}main/Heat_Power_Consumption", topics=[ + f"{mqtt_prefix}extra/Heat_Power_Consumption_Extra", # XTOP3, fw >= 3.2.3 f"{mqtt_prefix}extra/Heat_Power_Consumption", # XTOP0 f"{mqtt_prefix}main/Heat_Power_Consumption", f"{mqtt_prefix}main/Heat_Energy_Consumption", @@ -999,8 +1001,10 @@ def build_sensors(mqtt_prefix: str) -> list[HeishaMonSensorEntityDescription]: heishamon_topic_id="TOP38", key=f"{mqtt_prefix}main/Cool_Power_Production", topics=[ - f"{mqtt_prefix}main/Cool_Energy_Production", + f"{mqtt_prefix}extra/Cool_Power_Production_Extra", # XTOP4, fw >= 3.2.3 f"{mqtt_prefix}extra/Cool_Power_Production", # XTOP4 + f"{mqtt_prefix}main/Cool_Power_Production", + f"{mqtt_prefix}main/Cool_Energy_Production", ], compute_state=first_positive, state_class=SensorStateClass.MEASUREMENT, @@ -1013,6 +1017,7 @@ def build_sensors(mqtt_prefix: str) -> list[HeishaMonSensorEntityDescription]: heishamon_topic_id="TOP39", key=f"{mqtt_prefix}main/Cool_Power_Consumption", topics=[ + f"{mqtt_prefix}extra/Cool_Power_Consumption_Extra", # XTOP1, fw >= 3.2.3 f"{mqtt_prefix}extra/Cool_Power_Consumption", # XTOP1 f"{mqtt_prefix}main/Cool_Power_Consumption", f"{mqtt_prefix}main/Cool_Energy_Consumption", @@ -1028,6 +1033,7 @@ def build_sensors(mqtt_prefix: str) -> list[HeishaMonSensorEntityDescription]: heishamon_topic_id="TOP40", key=f"{mqtt_prefix}main/DHW_Power_Production", topics=[ + f"{mqtt_prefix}extra/DHW_Power_Production_Extra", # XTOP5, fw >= 3.2.3 f"{mqtt_prefix}extra/DHW_Power_Production", # XTOP5 f"{mqtt_prefix}main/DHW_Power_Production", f"{mqtt_prefix}main/DHW_Energy_Production", @@ -1042,6 +1048,7 @@ def build_sensors(mqtt_prefix: str) -> list[HeishaMonSensorEntityDescription]: heishamon_topic_id="TOP41", key=f"{mqtt_prefix}main/DHW_Power_Consumption", topics=[ + f"{mqtt_prefix}extra/DHW_Power_Consumption_Extra", # XTOP2, fw >= 3.2.3 f"{mqtt_prefix}extra/DHW_Power_Consumption", # XTOP2 f"{mqtt_prefix}main/DHW_Power_Consumption", f"{mqtt_prefix}main/DHW_Energy_Consumption", diff --git a/custom_components/aquarea/sensor.py b/custom_components/aquarea/sensor.py index 8a3d3c9..602d73a 100644 --- a/custom_components/aquarea/sensor.py +++ b/custom_components/aquarea/sensor.py @@ -84,7 +84,11 @@ async def async_setup_entry( native_unit_of_measurement="W", state_class=SensorStateClass.MEASUREMENT, topics=[ - # K & L models + # K & L models, fw >= 3.2.3 + f"{discovery_prefix}extra/DHW_Power_Production_Extra", + f"{discovery_prefix}extra/Heat_Power_Production_Extra", + f"{discovery_prefix}extra/Cool_Power_Production_Extra", + # K & L models, 3.2 <= fw < 3.2.3 f"{discovery_prefix}extra/DHW_Power_Production", f"{discovery_prefix}extra/Heat_Power_Production", f"{discovery_prefix}extra/Cool_Power_Production", @@ -110,7 +114,11 @@ async def async_setup_entry( native_unit_of_measurement="W", state_class=SensorStateClass.MEASUREMENT, topics=[ - # K & L models + # K & L models, fw >= 3.2.3 + f"{discovery_prefix}extra/DHW_Power_Consumption_Extra", + f"{discovery_prefix}extra/Heat_Power_Consumption_Extra", + f"{discovery_prefix}extra/Cool_Power_Consumption_Extra", + # K & L models, 3.2.0 <= fw < 3.2.3 f"{discovery_prefix}extra/DHW_Power_Consumption", f"{discovery_prefix}extra/Heat_Power_Consumption", f"{discovery_prefix}extra/Cool_Power_Consumption", @@ -147,13 +155,20 @@ async def async_setup_entry( f"{discovery_prefix}main/DHW_Energy_Consumption", f"{discovery_prefix}main/Heat_Energy_Consumption", f"{discovery_prefix}main/Cool_Energy_Consumption", - # K & L models + # K & L models, firmware 3.2.0 <= x < 3.2.3 f"{discovery_prefix}extra/DHW_Power_Production", f"{discovery_prefix}extra/Heat_Power_Production", f"{discovery_prefix}extra/Cool_Power_Production", f"{discovery_prefix}extra/DHW_Power_Consumption", f"{discovery_prefix}extra/Heat_Power_Consumption", f"{discovery_prefix}extra/Cool_Power_Consumption", + # K & L models, firmware >= 3.2.3 + f"{discovery_prefix}extra/DHW_Power_Production_Extra", + f"{discovery_prefix}extra/Heat_Power_Production_Extra", + f"{discovery_prefix}extra/Cool_Power_Production_Extra", + f"{discovery_prefix}extra/DHW_Power_Consumption_Extra", + f"{discovery_prefix}extra/Heat_Power_Consumption_Extra", + f"{discovery_prefix}extra/Cool_Power_Consumption_Extra", ], compute_state=compute_cop, ) @@ -162,9 +177,9 @@ async def async_setup_entry( def compute_cop(values) -> Optional[float]: - assert len(values) == 18 - production = extract_sum(values[12:15] + values[0:3] + values[6:9]) - consumption = extract_sum(values[15:18] + values[3:6] + values[9:12]) + assert len(values) == 24 + production = extract_sum(values[18:21] + values[12:15] + values[0:3] + values[6:9]) + consumption = extract_sum(values[21:24] + values[15:18] + values[3:6] + values[9:12]) if consumption == 0: return 0 cop = production / consumption