Home Assistant Unofficial Reference 2024.12.1
atlantic_pass_apc_dhw.py
Go to the documentation of this file.
1 """Support for Atlantic Pass APC DHW."""
2 
3 from typing import Any, cast
4 
5 from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState
6 
8  STATE_ECO,
9  STATE_HEAT_PUMP,
10  STATE_OFF,
11  STATE_PERFORMANCE,
12  WaterHeaterEntity,
13  WaterHeaterEntityFeature,
14 )
15 from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
16 
17 from ..entity import OverkizEntity
18 
19 
21  """Representation of Atlantic Pass APC DHW."""
22 
23  _attr_temperature_unit = UnitOfTemperature.CELSIUS
24  _attr_supported_features = (
25  WaterHeaterEntityFeature.TARGET_TEMPERATURE
26  | WaterHeaterEntityFeature.OPERATION_MODE
27  | WaterHeaterEntityFeature.AWAY_MODE
28  )
29  _attr_operation_list = [STATE_OFF, STATE_HEAT_PUMP, STATE_PERFORMANCE]
30 
31  @property
32  def target_temperature(self) -> float:
33  """Return the temperature corresponding to the PRESET."""
34  if self.is_boost_mode_onis_boost_mode_on:
35  return cast(
36  float,
37  self.executorexecutor.select_state(
38  OverkizState.CORE_COMFORT_TARGET_DWH_TEMPERATURE
39  ),
40  )
41 
42  if self.is_eco_mode_onis_eco_mode_on:
43  return cast(
44  float,
45  self.executorexecutor.select_state(
46  OverkizState.CORE_ECO_TARGET_DWH_TEMPERATURE
47  ),
48  )
49 
50  return cast(
51  float,
52  self.executorexecutor.select_state(OverkizState.CORE_TARGET_DWH_TEMPERATURE),
53  )
54 
55  async def async_set_temperature(self, **kwargs: Any) -> None:
56  """Set new temperature."""
57  temperature = kwargs[ATTR_TEMPERATURE]
58 
59  if self.is_eco_mode_onis_eco_mode_on:
60  await self.executorexecutor.async_execute_command(
61  OverkizCommand.SET_ECO_TARGET_DHW_TEMPERATURE, temperature
62  )
63  await self.executorexecutor.async_execute_command(
64  OverkizCommand.REFRESH_ECO_TARGET_DWH_TEMPERATURE
65  )
66  else:
67  await self.executorexecutor.async_execute_command(
68  OverkizCommand.SET_COMFORT_TARGET_DHW_TEMPERATURE, temperature
69  )
70  await self.executorexecutor.async_execute_command(
71  OverkizCommand.REFRESH_COMFORT_TARGET_DWH_TEMPERATURE
72  )
73  await self.executorexecutor.async_execute_command(
74  OverkizCommand.REFRESH_TARGET_DWH_TEMPERATURE
75  )
76 
77  @property
78  def is_boost_mode_on(self) -> bool:
79  """Return true if boost mode is on."""
80  return (
81  self.executorexecutor.select_state(OverkizState.CORE_BOOST_ON_OFF)
82  == OverkizCommandParam.ON
83  )
84 
85  @property
86  def is_eco_mode_on(self) -> bool:
87  """Return true if eco mode is on."""
88  return (
89  self.executorexecutor.select_state(OverkizState.IO_PASS_APCDWH_MODE)
90  == OverkizCommandParam.ECO
91  )
92 
93  @property
94  def is_away_mode_on(self) -> bool:
95  """Return true if away mode is on."""
96  return (
97  self.executorexecutor.select_state(OverkizState.CORE_DWH_ON_OFF)
98  == OverkizCommandParam.OFF
99  )
100 
101  @property
102  def current_operation(self) -> str:
103  """Return current operation."""
104  if self.is_boost_mode_onis_boost_mode_on:
105  return STATE_PERFORMANCE
106  if self.is_eco_mode_onis_eco_mode_on:
107  return STATE_ECO
108  if self.is_away_mode_onis_away_mode_onis_away_mode_on:
109  return STATE_OFF
110  return STATE_HEAT_PUMP
111 
112  async def async_set_operation_mode(self, operation_mode: str) -> None:
113  """Set new operation mode."""
114  boost_state = OverkizCommandParam.OFF
115  regular_state = OverkizCommandParam.OFF
116  if operation_mode == STATE_PERFORMANCE:
117  boost_state = OverkizCommandParam.ON
118  regular_state = OverkizCommandParam.ON
119  elif operation_mode == STATE_HEAT_PUMP:
120  regular_state = OverkizCommandParam.ON
121 
122  await self.executorexecutor.async_execute_command(
123  OverkizCommand.SET_BOOST_ON_OFF_STATE, boost_state
124  )
125  await self.executorexecutor.async_execute_command(
126  OverkizCommand.SET_DHW_ON_OFF_STATE, regular_state
127  )
128 
129  async def async_turn_away_mode_on(self) -> None:
130  """Turn away mode on."""
131  await self.executorexecutor.async_execute_command(
132  OverkizCommand.SET_BOOST_ON_OFF_STATE, OverkizCommandParam.OFF
133  )
134  await self.executorexecutor.async_execute_command(
135  OverkizCommand.SET_DHW_ON_OFF_STATE, OverkizCommandParam.OFF
136  )
137 
138  async def async_turn_away_mode_off(self) -> None:
139  """Turn away mode off."""
140  await self.executorexecutor.async_execute_command(
141  OverkizCommand.SET_BOOST_ON_OFF_STATE, OverkizCommandParam.OFF
142  )
143  await self.executorexecutor.async_execute_command(
144  OverkizCommand.SET_DHW_ON_OFF_STATE, OverkizCommandParam.ON
145  )