Update overkiz Atlantic Water Heater operation mode switching (#124619)

* conventional operation state usage

* MartinHjelmare indentation request

* Manual Mode binary sensor

* Removed usage of unconventional operation states

* Removed usage of unconventional operation state

* STATE_OFF operation mode support
This commit is contained in:
Alexey ALERT Rubashёff 2024-08-26 22:31:07 +03:00 committed by GitHub
parent b960ebeb8b
commit 0fe939cd7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 25 deletions

View File

@ -115,14 +115,24 @@ BINARY_SENSOR_DESCRIPTIONS: list[OverkizBinarySensorDescription] = [
OverkizBinarySensorDescription( OverkizBinarySensorDescription(
key=OverkizState.MODBUSLINK_DHW_ABSENCE_MODE, key=OverkizState.MODBUSLINK_DHW_ABSENCE_MODE,
name="Absence mode", name="Absence mode",
value_fn=lambda state: state value_fn=(
in (OverkizCommandParam.ON, OverkizCommandParam.PROG), lambda state: state in (OverkizCommandParam.ON, OverkizCommandParam.PROG)
),
), ),
OverkizBinarySensorDescription( OverkizBinarySensorDescription(
key=OverkizState.MODBUSLINK_DHW_BOOST_MODE, key=OverkizState.MODBUSLINK_DHW_BOOST_MODE,
name="Boost mode", name="Boost mode",
value_fn=lambda state: state value_fn=(
in (OverkizCommandParam.ON, OverkizCommandParam.PROG), lambda state: state in (OverkizCommandParam.ON, OverkizCommandParam.PROG)
),
),
OverkizBinarySensorDescription(
key=OverkizState.MODBUSLINK_DHW_MODE,
name="Manual mode",
value_fn=(
lambda state: state
in (OverkizCommandParam.MANUAL, OverkizCommandParam.MANUAL_ECO_INACTIVE)
),
), ),
] ]

View File

@ -6,6 +6,7 @@ from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState
from homeassistant.components.water_heater import ( from homeassistant.components.water_heater import (
STATE_ECO, STATE_ECO,
STATE_ELECTRIC,
STATE_OFF, STATE_OFF,
STATE_PERFORMANCE, STATE_PERFORMANCE,
WaterHeaterEntity, WaterHeaterEntity,
@ -28,9 +29,10 @@ class AtlanticDomesticHotWaterProductionMBLComponent(OverkizEntity, WaterHeaterE
| WaterHeaterEntityFeature.ON_OFF | WaterHeaterEntityFeature.ON_OFF
) )
_attr_operation_list = [ _attr_operation_list = [
OverkizCommandParam.PERFORMANCE, STATE_ECO,
OverkizCommandParam.ECO, STATE_OFF,
OverkizCommandParam.MANUAL, STATE_PERFORMANCE,
STATE_ELECTRIC,
] ]
def __init__( def __init__(
@ -116,20 +118,20 @@ class AtlanticDomesticHotWaterProductionMBLComponent(OverkizEntity, WaterHeaterE
cast(str, self.executor.select_state(OverkizState.MODBUSLINK_DHW_MODE)) cast(str, self.executor.select_state(OverkizState.MODBUSLINK_DHW_MODE))
== OverkizCommandParam.MANUAL_ECO_INACTIVE == OverkizCommandParam.MANUAL_ECO_INACTIVE
): ):
return OverkizCommandParam.MANUAL # STATE_ELECTRIC is a substitution for OverkizCommandParam.MANUAL
# to keep up with the conventional state usage only
# https://developers.home-assistant.io/docs/core/entity/water-heater/#states
return STATE_ELECTRIC
return STATE_OFF return STATE_OFF
async def async_set_operation_mode(self, operation_mode: str) -> None: async def async_set_operation_mode(self, operation_mode: str) -> None:
"""Set new operation mode.""" """Set new operation mode."""
if operation_mode in (STATE_PERFORMANCE, OverkizCommandParam.BOOST): if operation_mode == STATE_PERFORMANCE:
if self.is_away_mode_on: if self.is_away_mode_on:
await self.async_turn_away_mode_off() await self.async_turn_away_mode_off()
await self.async_turn_boost_mode_on() await self.async_turn_boost_mode_on()
elif operation_mode in ( elif operation_mode == STATE_ECO:
OverkizCommandParam.ECO,
OverkizCommandParam.MANUAL_ECO_ACTIVE,
):
if self.is_away_mode_on: if self.is_away_mode_on:
await self.async_turn_away_mode_off() await self.async_turn_away_mode_off()
if self.is_boost_mode_on: if self.is_boost_mode_on:
@ -137,10 +139,7 @@ class AtlanticDomesticHotWaterProductionMBLComponent(OverkizEntity, WaterHeaterE
await self.executor.async_execute_command( await self.executor.async_execute_command(
OverkizCommand.SET_DHW_MODE, OverkizCommandParam.AUTO_MODE OverkizCommand.SET_DHW_MODE, OverkizCommandParam.AUTO_MODE
) )
elif operation_mode in ( elif operation_mode == STATE_ELECTRIC:
OverkizCommandParam.MANUAL,
OverkizCommandParam.MANUAL_ECO_INACTIVE,
):
if self.is_away_mode_on: if self.is_away_mode_on:
await self.async_turn_away_mode_off() await self.async_turn_away_mode_off()
if self.is_boost_mode_on: if self.is_boost_mode_on:
@ -148,14 +147,8 @@ class AtlanticDomesticHotWaterProductionMBLComponent(OverkizEntity, WaterHeaterE
await self.executor.async_execute_command( await self.executor.async_execute_command(
OverkizCommand.SET_DHW_MODE, OverkizCommandParam.MANUAL_ECO_INACTIVE OverkizCommand.SET_DHW_MODE, OverkizCommandParam.MANUAL_ECO_INACTIVE
) )
else: elif operation_mode == STATE_OFF:
if self.is_away_mode_on: await self.async_turn_away_mode_on()
await self.async_turn_away_mode_off()
if self.is_boost_mode_on:
await self.async_turn_boost_mode_off()
await self.executor.async_execute_command(
OverkizCommand.SET_DHW_MODE, operation_mode
)
async def async_turn_away_mode_on(self) -> None: async def async_turn_away_mode_on(self) -> None:
"""Turn away mode on.""" """Turn away mode on."""