Skip to content

Commit

Permalink
Merge branch 'main' of ssh://github.com/kamaradclimber/heishamon-home…
Browse files Browse the repository at this point in the history
…assistant

* 'main' of ssh://github.com/kamaradclimber/heishamon-homeassistant:
  Use a dictionary instead of repeating values for smart grid mode (#242)
  Update heatpump models (#241)
  Retain volatile optional pcb settings (#243)
  • Loading branch information
kamaradclimber committed Sep 7, 2024
2 parents 064b0dc + 42cca0f commit f90fc32
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
36 changes: 15 additions & 21 deletions custom_components/aquarea/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ def read_mixing_valve_request(value: str) -> Optional[str]:
}


SMART_GRID_MODES_STRING = {
"0": "Normal",
"1": "Capacity 1",
"2": "HP/DHW off",
"3": "Capacity 2",
}


def read_zones_state(value):
return ZONE_STATES_STRING.get(value, f"Unknown zone state value: {value}")

Expand Down Expand Up @@ -356,27 +364,11 @@ def write_demandcontrol(value: int) -> str:


def read_smart_grid_mode(value: str) -> str:
if value == "0":
return "Normal"
elif value == "1":
return "Capacity 1"
elif value == "2":
return "HP/DHW off"
elif value == "3":
return "Capacity 2"
return str(value)
return SMART_GRID_MODES_STRING.get(value, f"Unknown smart grid mode: {value}")


def write_smart_grid_mode(value: str) -> str:
if value == "Normal":
return "0"
elif value == "Capacity 1":
return "1"
elif value == "HP/DHW off":
return "2"
elif value == "Capacity 2":
return "3"
return str(value)
return lookup_by_value(SMART_GRID_MODES_STRING, value)


def read_quiet_mode(value: str) -> str:
Expand Down Expand Up @@ -647,8 +639,9 @@ def build_numbers(mqtt_prefix: str) -> list[HeishaMonNumberEntityDescription]:
),
HeishaMonNumberEntityDescription(
heishamon_topic_id="SetDemandControl",
key=f"{mqtt_prefix}main/FakeDemandControl", # FIXME: find how to get real value
key=f"{mqtt_prefix}commands/SetDemandControl",
command_topic=f"{mqtt_prefix}commands/SetDemandControl",
retain=True,
name="Demand Control",
entity_category=EntityCategory.CONFIG,
native_unit_of_measurement="%",
Expand Down Expand Up @@ -782,13 +775,14 @@ def build_selects(mqtt_prefix: str) -> list[HeishaMonSelectEntityDescription]:
),
HeishaMonSelectEntityDescription(
heishamon_topic_id="SetSmartGridMode",
key=f"{mqtt_prefix}main/FakeSmartGridMode", # FIXME: find how to get real value
key=f"{mqtt_prefix}commands/SetSmartGridMode",
command_topic=f"{mqtt_prefix}commands/SetSmartGridMode",
retain=True,
name="Smart Grid Mode",
entity_category=EntityCategory.CONFIG,
state=read_smart_grid_mode,
state_to_mqtt=write_smart_grid_mode,
options=["Normal", "HP/DHW off", "Capacity 1", "Capacity 2"],
options=list(SMART_GRID_MODES_STRING.values()),
entity_registry_enabled_default=False, # comes from the optional PCB: disabled by default
),
]
Expand Down
13 changes: 8 additions & 5 deletions custom_components/aquarea/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@
"35": "WH-SXC09H3E8 9 3ph T-CAP - new version",
"36": "WH-ADC0309K3E5AN 7 1ph HP - All-In-One K-series - AN",
"37": "WH-SDC0309K3E5 5 1ph HP - split K-series",
"38": "WH-SDC0309K3E5 7 1ph HP - split K-series",
"39": "WH-ADC0916H9E8 16 3ph T-CAP - All-In-One",
"40": "WH-ADC0912H9E8 12 3ph T-CAP - All-In-One",
"41": "WH-SDC12H9E8 12 3ph HP",
"42": "WH-MXC16J9E8 16 3ph T-CAP",
"38": "WH-SDC0509L3E5 9 1 ph HP - split L-series 3kW elec heating",
"39": "WH-SDC12H9E8 12 3ph HP",
"40": "WH-SDC0309K3E5 7 1ph HP - split K-series",
"41": "WH-ADC0916H9E8 16 3ph T-CAP - All-In-One",
"42": "WH-ADC0912H9E8 12 3ph T-CAP - All-In-One",
"43": "WH-MXC16J9E8 16 3ph T-CAP",
"44": "WH-MXC12J6E5 12 1ph T-CAP",
"45": "WH-SQC09H3E8 9 3ph T-CAP - Super Quiet revised model",
}

0 comments on commit f90fc32

Please sign in to comment.