Fix DHWP overkiz_to_operation_mode creation list (#83885)
* Fix dhWP overkiz_to_operation_mode creation list * Improve operation__list too and rename var * Improve if condition * Improve state_modefintion test Co-authored-by: Thibaut <thibaut@etienne.pw> Co-authored-by: Thibaut <thibaut@etienne.pw>
This commit is contained in:
parent
d9c19e6e11
commit
6ee8c8b60e
1 changed files with 12 additions and 11 deletions
|
@ -29,8 +29,6 @@ OVERKIZ_TO_OPERATION_MODE: dict[str, str] = {
|
||||||
OverkizCommandParam.BOOST: STATE_PERFORMANCE,
|
OverkizCommandParam.BOOST: STATE_PERFORMANCE,
|
||||||
}
|
}
|
||||||
|
|
||||||
OPERATION_MODE_TO_OVERKIZ = {v: k for k, v in OVERKIZ_TO_OPERATION_MODE.items()}
|
|
||||||
|
|
||||||
DHWP_AWAY_MODES = [
|
DHWP_AWAY_MODES = [
|
||||||
OverkizCommandParam.ABSENCE,
|
OverkizCommandParam.ABSENCE,
|
||||||
OverkizCommandParam.AWAY,
|
OverkizCommandParam.AWAY,
|
||||||
|
@ -49,7 +47,6 @@ class DomesticHotWaterProduction(OverkizEntity, WaterHeaterEntity):
|
||||||
WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||||
| WaterHeaterEntityFeature.OPERATION_MODE
|
| WaterHeaterEntityFeature.OPERATION_MODE
|
||||||
)
|
)
|
||||||
_attr_operation_list = [*OPERATION_MODE_TO_OVERKIZ]
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, device_url: str, coordinator: OverkizDataUpdateCoordinator
|
self, device_url: str, coordinator: OverkizDataUpdateCoordinator
|
||||||
|
@ -58,17 +55,21 @@ class DomesticHotWaterProduction(OverkizEntity, WaterHeaterEntity):
|
||||||
super().__init__(device_url, coordinator)
|
super().__init__(device_url, coordinator)
|
||||||
|
|
||||||
# Init operation mode to set for this specific device
|
# Init operation mode to set for this specific device
|
||||||
self.overkiz_to_operation_mode: dict[str, str] = {}
|
self.operation_mode_to_overkiz: dict[str, str] = {}
|
||||||
|
self._attr_operation_list = []
|
||||||
state_mode_definition = self.executor.select_definition_state(
|
state_mode_definition = self.executor.select_definition_state(
|
||||||
OverkizState.IO_DHW_MODE, OverkizState.MODBUSLINK_DHW_MODE
|
OverkizState.IO_DHW_MODE, OverkizState.MODBUSLINK_DHW_MODE
|
||||||
)
|
)
|
||||||
if state_mode_definition and state_mode_definition.values:
|
for param, mode in OVERKIZ_TO_OPERATION_MODE.items():
|
||||||
# Filter only for mode allowed by this device
|
# Filter only for mode allowed by this device
|
||||||
for param, mode in OVERKIZ_TO_OPERATION_MODE.items():
|
# or allow all if no mode definition found
|
||||||
if param in state_mode_definition.values:
|
if (
|
||||||
self.overkiz_to_operation_mode[param] = mode
|
not state_mode_definition
|
||||||
else:
|
or state_mode_definition.values
|
||||||
self.overkiz_to_operation_mode = OVERKIZ_TO_OPERATION_MODE
|
and param in state_mode_definition.values
|
||||||
|
):
|
||||||
|
self.operation_mode_to_overkiz[mode] = param
|
||||||
|
self._attr_operation_list.append(param)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _is_boost_mode_on(self) -> bool:
|
def _is_boost_mode_on(self) -> bool:
|
||||||
|
@ -323,7 +324,7 @@ class DomesticHotWaterProduction(OverkizEntity, WaterHeaterEntity):
|
||||||
)
|
)
|
||||||
|
|
||||||
await self.executor.async_execute_command(
|
await self.executor.async_execute_command(
|
||||||
OverkizCommand.SET_DHW_MODE, self.overkiz_to_operation_mode[operation_mode]
|
OverkizCommand.SET_DHW_MODE, self.operation_mode_to_overkiz[operation_mode]
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.executor.has_command(OverkizCommand.REFRESH_BOOST_MODE_DURATION):
|
if self.executor.has_command(OverkizCommand.REFRESH_BOOST_MODE_DURATION):
|
||||||
|
|
Loading…
Add table
Reference in a new issue