Skip to content

Commit

Permalink
✨ Prepare firmware 3.2.3+ support
Browse files Browse the repository at this point in the history
Several topics have been renamed
  • Loading branch information
kamaradclimber committed Nov 1, 2023
1 parent c92e05b commit 943c186
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
9 changes: 8 additions & 1 deletion custom_components/aquarea/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
27 changes: 21 additions & 6 deletions custom_components/aquarea/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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,
)
Expand All @@ -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
Expand Down

0 comments on commit 943c186

Please sign in to comment.