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

Add Overkiz AtlanticPassAPCDHW #78665

Merged
merged 19 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
84394d0
Add Overkiz AtlanticPassAPCDHW
nyroDev Sep 17, 2022
a47be91
Remove unnecessary line
nyroDev Sep 18, 2022
0dcae13
Improve atlantic pass_apcdhw for operation and target temprature
nyroDev Sep 22, 2022
26521ff
Merge branch 'overkiz/atlantic_pass_apcdhw' of https://github.com/nyr…
nyroDev Sep 22, 2022
cc74bc6
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apcdhw
nyroDev Sep 26, 2022
5b18adb
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apcdhw
nyroDev Oct 3, 2022
e496669
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apcdhw
nyroDev Oct 4, 2022
00a7794
Remove async_execute_commands
nyroDev Oct 4, 2022
e740f56
Fix small code issues for Overkiz AtlanticPassAPCDHW
nyroDev Oct 5, 2022
3b6e0d2
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apcdhw
nyroDev Oct 17, 2022
76ec988
Update homeassistant/components/overkiz/const.py
nyroDev Oct 17, 2022
0092b92
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apcdhw
nyroDev Oct 28, 2022
75f8ca6
Update homeassistant/components/overkiz/water_heater_entities/atlanti…
nyroDev Nov 3, 2022
9edd75a
Update homeassistant/components/overkiz/water_heater_entities/atlanti…
nyroDev Nov 3, 2022
a5c8902
Fix small issues
nyroDev Nov 3, 2022
dc20a5c
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apcdhw
nyroDev Nov 3, 2022
b43289d
Merge branch 'dev' into overkiz/atlantic_pass_apcdhw
nyroDev Nov 4, 2022
30d7e31
Merge branch 'dev' into overkiz/atlantic_pass_apcdhw
Quentame Nov 4, 2022
49999db
Merge branch 'overkiz/atlantic_pass_apcdhw' of https://github.com/nyr…
nyroDev Nov 4, 2022
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
2 changes: 2 additions & 0 deletions homeassistant/components/overkiz/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
Platform.SENSOR,
Platform.SIREN,
Platform.SWITCH,
Platform.WATER_HEATER,
]

IGNORED_OVERKIZ_DEVICES: list[UIClass | UIWidget] = [
Expand Down Expand Up @@ -77,6 +78,7 @@
UIWidget.STATEFUL_ALARM_CONTROLLER: Platform.ALARM_CONTROL_PANEL, # widgetName, uiClass is Alarm (not supported)
UIWidget.STATELESS_EXTERIOR_HEATING: Platform.SWITCH, # widgetName, uiClass is ExteriorHeatingSystem (not supported)
UIWidget.TSKALARM_CONTROLLER: Platform.ALARM_CONTROL_PANEL, # widgetName, uiClass is Alarm (not supported)
UIWidget.ATLANTIC_PASS_APC_DHW: Platform.WATER_HEATER, # widgetName, uiClass is Water heater (not supported)
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
}

# Map Overkiz camelCase to Home Assistant snake_case for translation
Expand Down
11 changes: 11 additions & 0 deletions homeassistant/components/overkiz/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ async def async_execute_command(self, command_name: str, *args: Any) -> None:

await self.coordinator.async_refresh()

async def async_execute_commands(self, commands: list[Command]) -> None:
"""Execute device commands in async context."""

await self.coordinator.client.execute_commands(
self.device.device_url,
commands,
"Home Assistant",
)

await self.coordinator.async_refresh()

async def async_cancel_command(
self, commands_to_cancel: list[OverkizCommand]
) -> bool:
Expand Down
28 changes: 28 additions & 0 deletions homeassistant/components/overkiz/water_heater.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Support for Overkiz water heater devices."""
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
from __future__ import annotations

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import HomeAssistantOverkizData
from .const import DOMAIN
from .water_heater_entities import WIDGET_TO_WATER_HEATER_ENTITY


async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Overkiz DHW from a config entry."""
data: HomeAssistantOverkizData = hass.data[DOMAIN][entry.entry_id]

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
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Water heater entities for the Overkiz (by Somfy) integration."""
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
from pyoverkiz.enums.ui import UIWidget

from .atlantic_pass_apc_dhw import AtlanticPassAPCDHW

WIDGET_TO_WATER_HEATER_ENTITY = {
UIWidget.ATLANTIC_PASS_APC_DHW: AtlanticPassAPCDHW,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
"""Support for Atlantic Pass APC Zone Control."""
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState
from pyoverkiz.models import Command

from homeassistant.components.water_heater import (
STATE_HEAT_PUMP,
STATE_PERFORMANCE,
WaterHeaterEntity,
WaterHeaterEntityFeature,
)
from homeassistant.const import STATE_OFF, TEMP_CELSIUS

from ..entity import OverkizEntity

OPERATION_LIST = [STATE_OFF, STATE_HEAT_PUMP, STATE_PERFORMANCE]
nyroDev marked this conversation as resolved.
Show resolved Hide resolved


class AtlanticPassAPCDHW(OverkizEntity, WaterHeaterEntity):
"""Representation of Atlantic Pass APC DHW."""

_attr_temperature_unit = TEMP_CELSIUS
_attr_supported_features = (
WaterHeaterEntityFeature.OPERATION_MODE | WaterHeaterEntityFeature.AWAY_MODE
)
_attr_operation_list = OPERATION_LIST
nyroDev marked this conversation as resolved.
Show resolved Hide resolved

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

@property
def is_boost_mode_on(self) -> bool:
"""Return true if away mode is on."""
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
return (
self.executor.select_state(OverkizState.CORE_BOOST_ON_OFF)
== OverkizCommandParam.ON
)

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

async def async_set_operation_mode(self, operation_mode: str) -> None:
"""Set new operation mode."""

nyroDev marked this conversation as resolved.
Show resolved Hide resolved
boost_state = OverkizCommandParam.OFF
regular_state = OverkizCommandParam.OFF
if operation_mode == STATE_PERFORMANCE:
boost_state = OverkizCommandParam.ON
regular_state = OverkizCommandParam.ON
elif operation_mode == STATE_HEAT_PUMP:
regular_state = OverkizCommandParam.ON

commands = [
Command(
OverkizCommand.SET_BOOST_ON_OFF_STATE,
[boost_state],
),
Command(
OverkizCommand.SET_DHW_ON_OFF_STATE,
[regular_state],
),
]
await self.executor.async_execute_commands(commands)

async def async_turn_away_mode_on(self) -> None:
"""Turn away mode on."""
commands = [
Command(
OverkizCommand.SET_BOOST_ON_OFF_STATE,
[OverkizCommandParam.OFF],
),
Command(
OverkizCommand.SET_DHW_ON_OFF_STATE,
[OverkizCommandParam.OFF],
),
]
await self.executor.async_execute_commands(commands)

async def async_turn_away_mode_off(self) -> None:
"""Turn away mode off."""
commands = [
Command(
OverkizCommand.SET_BOOST_ON_OFF_STATE,
[OverkizCommandParam.OFF],
),
Command(
OverkizCommand.SET_DHW_ON_OFF_STATE,
[OverkizCommandParam.ON],
),
]

await self.executor.async_execute_commands(commands)