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 AtlanticPassAPCHeatingAndCoolingZone #78659

Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
daaea46
Add Overkiz AtlanticPassAPCHeatingAndCoolingZone
nyroDev Sep 17, 2022
2b42f7b
Fix commands instanciations to be simpler
nyroDev Sep 17, 2022
4ea72b8
Update AtlanticPassAPCHeatingAndCoolingZone to show temperature and f…
nyroDev Sep 21, 2022
c483c44
Simplify async_execute_commands in order to receive simpler list
nyroDev Sep 21, 2022
5dc7948
Fix get and set temperature in derogation or auto mode
nyroDev Sep 21, 2022
3aea914
Remove hvac_action from AtlanticPassAPCHeatingAndCoolingZone
nyroDev Sep 22, 2022
d51205f
Remove unused lines
nyroDev Sep 23, 2022
b5c4f9f
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Sep 26, 2022
2b6f4a4
Merge branch 'overkiz/atlantic_pass_apc_heating_and_cooling_zone' of …
nyroDev Sep 26, 2022
6cfce13
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Sep 28, 2022
dc20991
Merge branch 'overkiz/atlantic_pass_apc_heating_and_cooling_zone' of …
nyroDev Sep 28, 2022
bd2548b
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Oct 1, 2022
8a807ea
Merge branch 'overkiz/atlantic_pass_apc_heating_and_cooling_zone' of …
nyroDev Oct 1, 2022
afb7367
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Oct 3, 2022
bc6287e
Merge branch 'overkiz/atlantic_pass_apc_heating_and_cooling_zone' of …
nyroDev Oct 3, 2022
4e3c9f8
Update async_execute_commands to work like async_execute_command
nyroDev Oct 3, 2022
bc1a51f
Improve to use preset_home for internal scheduling
nyroDev Oct 3, 2022
2e454b2
Remove async_execute_commands
nyroDev Oct 4, 2022
972a2df
Improvement for AtlanticPassAPCHeatingAndCoolingZone
nyroDev Oct 5, 2022
533b1b8
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Oct 17, 2022
82abacb
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Oct 28, 2022
c817ba9
Update homeassistant/components/overkiz/climate_entities/__init__.py
nyroDev Nov 3, 2022
e36c56f
Update homeassistant/components/overkiz/climate_entities/atlantic_pas…
nyroDev Nov 3, 2022
ed0c7eb
Update homeassistant/components/overkiz/climate_entities/atlantic_pas…
nyroDev Nov 3, 2022
4c1f098
Update homeassistant/components/overkiz/const.py
nyroDev Nov 3, 2022
0d92ab0
Merge branch 'home-assistant:dev' into overkiz/atlantic_pass_apc_heat…
nyroDev Nov 3, 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from .atlantic_electrical_heater import AtlanticElectricalHeater
from .atlantic_electrical_towel_dryer import AtlanticElectricalTowelDryer
from .atlantic_heat_recovery_ventilation import AtlanticHeatRecoveryVentilation
from .atlantic_pass_apc_heating_and_cooling_zone import (
AtlanticPassAPCHeatingAndCoolingZone,
)
from .atlantic_pass_apc_zone_control import AtlanticPassAPCZoneControl
from .somfy_thermostat import SomfyThermostat

Expand All @@ -12,5 +15,6 @@
UIWidget.ATLANTIC_ELECTRICAL_TOWEL_DRYER: AtlanticElectricalTowelDryer,
UIWidget.ATLANTIC_HEAT_RECOVERY_VENTILATION: AtlanticHeatRecoveryVentilation,
UIWidget.ATLANTIC_PASS_APC_ZONE_CONTROL: AtlanticPassAPCZoneControl,
UIWidget.ATLANTIC_PASS_APC_HEATING_AND_COOLING_ZONE: AtlanticPassAPCHeatingAndCoolingZone,
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
UIWidget.SOMFY_THERMOSTAT: SomfyThermostat,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
"""Support for Atlantic Pass APC Heating And Cooling Zone Control."""
from __future__ import annotations

from typing import Any, cast

from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState

from homeassistant.components.climate import (
PRESET_AWAY,
PRESET_COMFORT,
PRESET_ECO,
PRESET_SLEEP,
ClimateEntity,
ClimateEntityFeature,
HVACMode,
)
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS

from ..coordinator import OverkizDataUpdateCoordinator
from ..entity import OverkizEntity

OVERKIZ_TO_HVAC_MODE: dict[str, str] = {
OverkizCommandParam.AUTO: HVACMode.AUTO,
OverkizCommandParam.ECO: HVACMode.AUTO,
OverkizCommandParam.MANU: HVACMode.HEAT,
OverkizCommandParam.HEATING: HVACMode.HEAT,
OverkizCommandParam.STOP: HVACMode.OFF,
OverkizCommandParam.INTERNAL_SCHEDULING: HVACMode.AUTO,
OverkizCommandParam.COMFORT: HVACMode.HEAT,
}

HVAC_MODE_TO_OVERKIZ = {v: k for k, v in OVERKIZ_TO_HVAC_MODE.items()}

OVERKIZ_TO_PRESET_MODES: dict[str, str] = {
OverkizCommandParam.OFF: PRESET_ECO,
OverkizCommandParam.STOP: PRESET_ECO,
OverkizCommandParam.COMFORT: PRESET_COMFORT,
OverkizCommandParam.MANU: PRESET_COMFORT,
OverkizCommandParam.ABSENCE: PRESET_AWAY,
OverkizCommandParam.ECO: PRESET_ECO,
OverkizCommandParam.INTERNAL_SCHEDULING: PRESET_COMFORT,
}

PRESET_MODES_TO_OVERKIZ = {v: k for k, v in OVERKIZ_TO_PRESET_MODES.items()}

OVERKIZ_TO_PROFILE_MODES: dict[str, str] = {
OverkizCommandParam.OFF: PRESET_SLEEP,
OverkizCommandParam.STOP: PRESET_SLEEP,
OverkizCommandParam.ECO: PRESET_ECO,
OverkizCommandParam.ABSENCE: PRESET_AWAY,
OverkizCommandParam.MANU: PRESET_COMFORT,
OverkizCommandParam.DEROGATION: PRESET_COMFORT,
OverkizCommandParam.COMFORT: PRESET_COMFORT,
}


class AtlanticPassAPCHeatingAndCoolingZone(OverkizEntity, ClimateEntity):
"""Representation of Atlantic Pass APC Heating And Cooling Zone Zone Control."""
nyroDev marked this conversation as resolved.
Show resolved Hide resolved

_attr_hvac_modes = [*HVAC_MODE_TO_OVERKIZ]
_attr_preset_modes = [*PRESET_MODES_TO_OVERKIZ]
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
_attr_temperature_unit = TEMP_CELSIUS

def __init__(
self, device_url: str, coordinator: OverkizDataUpdateCoordinator
) -> None:
"""Init method."""
super().__init__(device_url, coordinator)
self.temperature_device = self.executor.linked_device(
int(self.device_url.split("#", 1)[1]) + 1
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
)

@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
if temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]:
return cast(float, temperature.value)

return None

@property
def hvac_mode(self) -> str:
"""Return hvac operation ie. heat, cool mode."""
return OVERKIZ_TO_HVAC_MODE[
cast(str, self.executor.select_state(OverkizState.IO_PASS_APC_HEATING_MODE))
]

async def async_set_hvac_mode(self, hvac_mode: str) -> None:
"""Set new target hvac mode."""
commands: list[list | str] = [
[
OverkizCommand.SET_PASS_APC_HEATING_MODE,
[HVAC_MODE_TO_OVERKIZ[hvac_mode]],
],
# We also needs to execute these 3 commands to make it work correctly
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
[
OverkizCommand.SET_DEROGATION_ON_OFF_STATE,
[OverkizCommandParam.OFF],
],
OverkizCommand.REFRESH_PASS_APC_HEATING_MODE,
OverkizCommand.REFRESH_PASS_APC_HEATING_PROFILE,
]
await self.executor.async_execute_commands(commands)

@property
def preset_mode(self) -> str:
"""Return the current preset mode, e.g., home, away, temp."""
heating_mode = cast(
str, self.executor.select_state(OverkizState.IO_PASS_APC_HEATING_MODE)
)

if heating_mode == OverkizCommandParam.INTERNAL_SCHEDULING:
# In Internal scheduling, it could be comfort or eco
return OVERKIZ_TO_PROFILE_MODES[
cast(
str,
self.executor.select_state(
OverkizState.IO_PASS_APC_HEATING_PROFILE
),
)
]

return OVERKIZ_TO_PRESET_MODES[heating_mode]

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode."""
commands: list[list | str] = [
[
OverkizCommand.SET_PASS_APC_HEATING_MODE,
[PRESET_MODES_TO_OVERKIZ[preset_mode]],
],
# We also needs to execute these 3 commands to make it work correctly
[
OverkizCommand.SET_DEROGATION_ON_OFF_STATE,
[OverkizCommandParam.OFF],
],
OverkizCommand.REFRESH_PASS_APC_HEATING_MODE,
OverkizCommand.REFRESH_PASS_APC_HEATING_PROFILE,
]

await self.executor.async_execute_commands(commands)

@property
def target_temperature(self) -> float:
"""Return hvac target temperature."""
current_profile = cast(
str,
self.executor.select_state(OverkizState.IO_PASS_APC_HEATING_PROFILE),
)

if current_profile == OverkizCommandParam.ECO:
return cast(
float,
self.executor.select_state(
OverkizState.CORE_ECO_HEATING_TARGET_TEMPERATURE
),
)
if current_profile == OverkizCommandParam.COMFORT:
return cast(
float,
self.executor.select_state(
OverkizState.CORE_COMFORT_HEATING_TARGET_TEMPERATURE
),
)
if current_profile == OverkizCommandParam.DEROGATION:
return cast(
float,
self.executor.select_state(
OverkizState.CORE_DEROGATED_TARGET_TEMPERATURE
),
)
nyroDev marked this conversation as resolved.
Show resolved Hide resolved

return cast(
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
float, self.executor.select_state(OverkizState.CORE_TARGET_TEMPERATURE)
)

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

if self.hvac_mode == HVACMode.AUTO:
commands_for_auto: list[list | str] = [
[
OverkizCommand.SET_COMFORT_HEATING_TARGET_TEMPERATURE,
[temperature],
],
OverkizCommand.REFRESH_COMFORT_HEATING_TARGET_TEMPERATURE,
OverkizCommand.REFRESH_TARGET_TEMPERATURE,
]
await self.executor.async_execute_commands(commands_for_auto)
else:
commands_for_other: list[list | str] = [
[
OverkizCommand.SET_DEROGATED_TARGET_TEMPERATURE,
[temperature],
],
[
OverkizCommand.SET_DEROGATION_ON_OFF_STATE,
[OverkizCommandParam.ON],
],
OverkizCommand.REFRESH_TARGET_TEMPERATURE,
OverkizCommand.REFRESH_PASS_APC_HEATING_MODE,
OverkizCommand.REFRESH_PASS_APC_HEATING_PROFILE,
]
await self.executor.async_execute_commands(commands_for_other)
1 change: 1 addition & 0 deletions homeassistant/components/overkiz/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
UIWidget.ATLANTIC_ELECTRICAL_TOWEL_DRYER: Platform.CLIMATE, # widgetName, uiClass is HeatingSystem (not supported)
UIWidget.ATLANTIC_HEAT_RECOVERY_VENTILATION: Platform.CLIMATE, # widgetName, uiClass is HeatingSystem (not supported)
UIWidget.ATLANTIC_PASS_APC_ZONE_CONTROL: Platform.CLIMATE, # widgetName, uiClass is HeatingSystem (not supported)
UIWidget.ATLANTIC_PASS_APC_HEATING_AND_COOLING_ZONE: Platform.CLIMATE, # widgetName, uiClass is HeatingSystem (not supported)
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
UIWidget.DOMESTIC_HOT_WATER_TANK: Platform.SWITCH, # widgetName, uiClass is WaterHeatingSystem (not supported)
UIWidget.MY_FOX_ALARM_CONTROLLER: Platform.ALARM_CONTROL_PANEL, # widgetName, uiClass is Alarm (not supported)
UIWidget.MY_FOX_SECURITY_CAMERA: Platform.SWITCH, # widgetName, uiClass is Camera (not supported)
Expand Down
18 changes: 18 additions & 0 deletions homeassistant/components/overkiz/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ 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[list | str]) -> None:
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
nyroDev marked this conversation as resolved.
Show resolved Hide resolved
"""Execute device commands in async context."""

commands_objects = []
for cmd in commands:
if isinstance(cmd, list):
commands_objects.append(Command(cmd[0], cmd[1]))
else:
commands_objects.append(Command(cmd))

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

await self.coordinator.async_refresh()

async def async_cancel_command(
self, commands_to_cancel: list[OverkizCommand]
) -> bool:
Expand Down