Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve AtlanticDomesticHotWaterProductionMBLComponent support in Overkiz #114178

Merged
merged 45 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5d704e2
add overkiz AtlanticDHW support
ALERTua Mar 25, 2024
281f877
Merge remote-tracking branch 'origin/dev' into atlantic_dhw
ALERTua Mar 25, 2024
a030627
Changed class annotation
ALERTua Mar 25, 2024
3ff8bae
min_temp and max_temp as properties
ALERTua Mar 25, 2024
8babfb7
Merge branch 'home-assistant:dev' into atlantic_dhw
ALERTua Mar 25, 2024
660db38
Merge branch 'dev' into atlantic_dhw
ALERTua Mar 25, 2024
6aa374d
reverted binary_sensors, number, sensor to make separate PRs
ALERTua Mar 25, 2024
42d1af7
Update homeassistant/components/overkiz/water_heater_entities/atlanti…
ALERTua Mar 29, 2024
a078282
Update homeassistant/components/overkiz/water_heater_entities/atlanti…
ALERTua Mar 29, 2024
abe325a
Update homeassistant/components/overkiz/water_heater_entities/atlanti…
ALERTua Mar 29, 2024
a4a1dac
Update homeassistant/components/overkiz/water_heater.py
ALERTua Mar 29, 2024
7d4ba53
Update homeassistant/components/overkiz/water_heater_entities/atlanti…
ALERTua Mar 29, 2024
eae3a95
Update homeassistant/components/overkiz/water_heater_entities/atlanti…
ALERTua Mar 29, 2024
70b2b82
Merge branch 'dev' into atlantic_dhw
ALERTua Mar 29, 2024
758431d
review fixes, typos, and pylint
ALERTua Mar 29, 2024
662fbde
review fix
ALERTua Mar 29, 2024
c19aee0
review fix
ALERTua Mar 29, 2024
2820a2e
ruff
ALERTua Mar 29, 2024
502ddda
temperature properties changed to constructor attributes
ALERTua Mar 29, 2024
f53da55
logger removed
ALERTua Mar 29, 2024
d4956e5
Merge branch 'dev' into atlantic_dhw
ALERTua Apr 8, 2024
9ef3f2c
constants usage consistency
ALERTua Apr 8, 2024
83a15a0
Merge branch 'dev' into atlantic_dhw
ALERTua Apr 8, 2024
9ce3974
redundant mapping removed
ALERTua Apr 8, 2024
35b20f7
Update homeassistant/components/overkiz/water_heater_entities/atlanti…
ALERTua Apr 8, 2024
202ede2
Merge branch 'dev' into atlantic_dhw
ALERTua Apr 8, 2024
29cf321
Merge branch 'dev' into atlantic_dhw
ALERTua Jun 21, 2024
87f5a84
boost mode method annotation typo
ALERTua Jun 21, 2024
1c13715
removed away mode for atlantic dwh
ALERTua Jun 21, 2024
8d868f7
absence and boost mode attributes now support 'prog' state
ALERTua Jun 21, 2024
01e5d4c
heating status bugfix
ALERTua Jun 23, 2024
66dd8a5
electrical consumption sensor
ALERTua Jun 23, 2024
6e9f7c6
warm water remaining volume sensor
ALERTua Jun 23, 2024
a7e68bd
away mode reintroduced
ALERTua Jun 23, 2024
a33d1fa
mypy check
ALERTua Jun 23, 2024
c9a5b91
Merge branch 'dev' into atlantic_dhw
ALERTua Jun 23, 2024
e7de373
boost plus state support
ALERTua Jun 23, 2024
0c484e7
Update homeassistant/components/overkiz/sensor.py
ALERTua Jun 24, 2024
eb78f9c
sensors reverted to separate them into their own PR
ALERTua Jun 24, 2024
ce7734d
check away and boost modes on before switching them off
ALERTua Jun 24, 2024
a7fab8d
atlantic_dhw renamed to atlantic_domestic_hot_water_production
ALERTua Jun 24, 2024
36c923e
Merge branch 'dev' into atlantic_dhw
ALERTua Jun 24, 2024
d4a12d7
annotation changed
ALERTua Jun 26, 2024
d39588c
Merge branch 'dev' into atlantic_dhw
ALERTua Jun 26, 2024
774decd
AtlanticDomesticHotWaterProductionMBLComponent file renamed, annotati…
ALERTua Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions homeassistant/components/overkiz/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,20 @@ class OverkizBinarySensorDescription(BinarySensorEntityDescription):
key=OverkizState.CORE_HEATING_STATUS,
name="Heating status",
device_class=BinarySensorDeviceClass.HEAT,
value_fn=lambda state: state == OverkizCommandParam.ON,
value_fn=lambda state: cast(str, state).lower()
ALERTua marked this conversation as resolved.
Show resolved Hide resolved
in (OverkizCommandParam.ON, OverkizCommandParam.HEATING),
),
OverkizBinarySensorDescription(
key=OverkizState.MODBUSLINK_DHW_ABSENCE_MODE,
name="Absence mode",
value_fn=lambda state: state == OverkizCommandParam.ON,
value_fn=lambda state: state
in (OverkizCommandParam.ON, OverkizCommandParam.PROG),
),
OverkizBinarySensorDescription(
key=OverkizState.MODBUSLINK_DHW_BOOST_MODE,
name="Boost mode",
value_fn=lambda state: state == OverkizCommandParam.ON,
value_fn=lambda state: state
in (OverkizCommandParam.ON, OverkizCommandParam.PROG),
ALERTua marked this conversation as resolved.
Show resolved Hide resolved
),
]

Expand Down
29 changes: 21 additions & 8 deletions homeassistant/components/overkiz/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

from . import HomeAssistantOverkizData
from .const import DOMAIN
from .water_heater_entities import WIDGET_TO_WATER_HEATER_ENTITY
from .entity import OverkizEntity
from .water_heater_entities import (
CONTROLLABLE_NAME_TO_WATER_HEATER_ENTITY,
WIDGET_TO_WATER_HEATER_ENTITY,
)


async def async_setup_entry(
Expand All @@ -19,11 +23,20 @@ async def async_setup_entry(
) -> None:
"""Set up the Overkiz DHW from a config entry."""
data: HomeAssistantOverkizData = hass.data[DOMAIN][entry.entry_id]
entities: list[OverkizEntity] = []

async_add_entities(
WIDGET_TO_WATER_HEATER_ENTITY[device.widget](
device.device_url, data.coordinator
)
for device in data.platforms[Platform.WATER_HEATER]
if device.widget in WIDGET_TO_WATER_HEATER_ENTITY
)
for device in data.platforms[Platform.WATER_HEATER]:
if device.controllable_name in CONTROLLABLE_NAME_TO_WATER_HEATER_ENTITY:
entities.append(
CONTROLLABLE_NAME_TO_WATER_HEATER_ENTITY[device.controllable_name](
device.device_url, data.coordinator
)
)
elif device.widget in WIDGET_TO_WATER_HEATER_ENTITY:
entities.append(
WIDGET_TO_WATER_HEATER_ENTITY[device.widget](
device.device_url, data.coordinator
)
)

async_add_entities(entities)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

from pyoverkiz.enums.ui import UIWidget

from .atlantic_domestic_hot_water_production_mlb_component import (
AtlanticDomesticHotWaterProductionMBLComponent,
)
from .atlantic_pass_apc_dhw import AtlanticPassAPCDHW
from .domestic_hot_water_production import DomesticHotWaterProduction
from .hitachi_dhw import HitachiDHW
Expand All @@ -11,3 +14,7 @@
UIWidget.DOMESTIC_HOT_WATER_PRODUCTION: DomesticHotWaterProduction,
UIWidget.HITACHI_DHW: HitachiDHW,
}

CONTROLLABLE_NAME_TO_WATER_HEATER_ENTITY = {
"modbuslink:AtlanticDomesticHotWaterProductionMBLComponent": AtlanticDomesticHotWaterProductionMBLComponent,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
"""Support for AtlanticDomesticHotWaterProductionMBLComponent."""

from typing import Any, cast

from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState

from homeassistant.components.water_heater import (
STATE_ECO,
STATE_OFF,
STATE_PERFORMANCE,
WaterHeaterEntity,
WaterHeaterEntityFeature,
)
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature

from .. import OverkizDataUpdateCoordinator
from ..entity import OverkizEntity


class AtlanticDomesticHotWaterProductionMBLComponent(OverkizEntity, WaterHeaterEntity):
"""Representation of AtlanticDomesticHotWaterProductionMBLComponent (modbuslink)."""

_attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_supported_features = (
WaterHeaterEntityFeature.TARGET_TEMPERATURE
| WaterHeaterEntityFeature.OPERATION_MODE
| WaterHeaterEntityFeature.AWAY_MODE
| WaterHeaterEntityFeature.ON_OFF
)
_attr_operation_list = [
OverkizCommandParam.PERFORMANCE,
OverkizCommandParam.ECO,
OverkizCommandParam.MANUAL,
]

def __init__(
self, device_url: str, coordinator: OverkizDataUpdateCoordinator
) -> None:
"""Init method."""
super().__init__(device_url, coordinator)
self._attr_max_temp = cast(
float,
self.executor.select_state(
OverkizState.CORE_MAXIMAL_TEMPERATURE_MANUAL_MODE
),
)
self._attr_min_temp = cast(
float,
self.executor.select_state(
OverkizState.CORE_MINIMAL_TEMPERATURE_MANUAL_MODE
),
)

@property
def current_temperature(self) -> float:
"""Return the current temperature."""
return cast(
float,
self.executor.select_state(
OverkizState.MODBUSLINK_MIDDLE_WATER_TEMPERATURE
),
)

@property
def target_temperature(self) -> float:
"""Return the temperature corresponding to the PRESET."""
return cast(
float,
self.executor.select_state(OverkizState.CORE_WATER_TARGET_TEMPERATURE),
)

async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new temperature."""
temperature = kwargs[ATTR_TEMPERATURE]
await self.executor.async_execute_command(
OverkizCommand.SET_TARGET_DHW_TEMPERATURE, temperature
)

@property
def is_boost_mode_on(self) -> bool:
"""Return true if boost mode is on."""
return self.executor.select_state(OverkizState.MODBUSLINK_DHW_BOOST_MODE) in (
OverkizCommandParam.ON,
OverkizCommandParam.PROG,
)

@property
def is_eco_mode_on(self) -> bool:
"""Return true if eco mode is on."""
return self.executor.select_state(OverkizState.MODBUSLINK_DHW_MODE) in (
OverkizCommandParam.MANUAL_ECO_ACTIVE,
OverkizCommandParam.AUTO_MODE,
)

@property
def is_away_mode_on(self) -> bool:
"""Return true if away mode is on."""
return (
self.executor.select_state(OverkizState.MODBUSLINK_DHW_ABSENCE_MODE)
== OverkizCommandParam.ON
)

@property
def current_operation(self) -> str:
"""Return current operation."""
if self.is_away_mode_on:
return STATE_OFF

if self.is_boost_mode_on:
return STATE_PERFORMANCE

if self.is_eco_mode_on:
return STATE_ECO

if (
cast(str, self.executor.select_state(OverkizState.MODBUSLINK_DHW_MODE))
== OverkizCommandParam.MANUAL_ECO_INACTIVE
):
return OverkizCommandParam.MANUAL
ALERTua marked this conversation as resolved.
Show resolved Hide resolved

return STATE_OFF

async def async_set_operation_mode(self, operation_mode: str) -> None:
"""Set new operation mode."""
if operation_mode in (STATE_PERFORMANCE, OverkizCommandParam.BOOST):
if self.is_away_mode_on:
await self.async_turn_away_mode_off()
await self.async_turn_boost_mode_on()
elif operation_mode in (
OverkizCommandParam.ECO,
OverkizCommandParam.MANUAL_ECO_ACTIVE,
):
if self.is_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, OverkizCommandParam.AUTO_MODE
)
elif operation_mode in (
OverkizCommandParam.MANUAL,
OverkizCommandParam.MANUAL_ECO_INACTIVE,
):
if self.is_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, OverkizCommandParam.MANUAL_ECO_INACTIVE
)
else:
if self.is_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:
"""Turn away mode on."""
await self.executor.async_execute_command(
OverkizCommand.SET_ABSENCE_MODE, OverkizCommandParam.ON
)

async def async_turn_away_mode_off(self) -> None:
"""Turn away mode off."""
await self.executor.async_execute_command(
OverkizCommand.SET_ABSENCE_MODE, OverkizCommandParam.OFF
)

async def async_turn_boost_mode_on(self) -> None:
"""Turn boost mode on."""
await self.executor.async_execute_command(
OverkizCommand.SET_BOOST_MODE, OverkizCommandParam.ON
)

async def async_turn_boost_mode_off(self) -> None:
"""Turn boost mode off."""
await self.executor.async_execute_command(
OverkizCommand.SET_BOOST_MODE, OverkizCommandParam.OFF
)