Home Assistant Unofficial Reference 2024.12.1
atlantic_pass_apc_heat_pump_main_component.py
Go to the documentation of this file.
1 """Support for Atlantic Pass APC Heat Pump Main Component."""
2 
3 from __future__ import annotations
4 
5 from asyncio import sleep
6 from typing import cast
7 
8 from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState
9 
11  ClimateEntity,
12  ClimateEntityFeature,
13  HVACMode,
14 )
15 from homeassistant.const import UnitOfTemperature
16 
17 from ..const import DOMAIN
18 from ..entity import OverkizEntity
19 
20 OVERKIZ_TO_HVAC_MODES: dict[str, HVACMode] = {
21  OverkizCommandParam.STOP: HVACMode.OFF,
22  OverkizCommandParam.HEATING: HVACMode.HEAT,
23  OverkizCommandParam.COOLING: HVACMode.COOL,
24 }
25 
26 HVAC_MODES_TO_OVERKIZ = {v: k for k, v in OVERKIZ_TO_HVAC_MODES.items()}
27 
28 
30  """Representation of Atlantic Pass APC Heat Pump Main Component.
31 
32  This component can only turn off the heating pump and select the working mode: heating or cooling.
33  To set new temperatures, they must be selected individually per Zones (ie: AtlanticPassAPCHeatingAndCoolingZone).
34  Once the Device is switched on into heating or cooling mode, the Heat Pump will be activated and will use
35  the default temperature configuration for each available zone.
36  """
37 
38  _attr_hvac_modes = [*HVAC_MODES_TO_OVERKIZ]
39  _attr_supported_features = (
40  ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON
41  )
42  _attr_temperature_unit = UnitOfTemperature.CELSIUS
43  _attr_translation_key = DOMAIN
44  _enable_turn_on_off_backwards_compatibility = False
45 
46  @property
47  def hvac_mode(self) -> HVACMode:
48  """Return hvac current mode: stop, cooling, heating."""
49  return OVERKIZ_TO_HVAC_MODES[
50  cast(
51  str, self.executorexecutor.select_state(OverkizState.IO_PASS_APC_OPERATING_MODE)
52  )
53  ]
54 
55  async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
56  """Set new target hvac mode: stop, cooling, heating."""
57  # They are mainly managed by the Zone Control device
58  # However, we can turn off or put the heat pump in cooling/ heating mode.
59  await self.executorexecutor.async_execute_command(
60  OverkizCommand.SET_PASS_APC_OPERATING_MODE,
61  HVAC_MODES_TO_OVERKIZ[hvac_mode],
62  )
63 
64  # Wait for 2 seconds to ensure the HVAC mode change is properly applied and system stabilizes.
65  await sleep(2)