From 315d59d615307d4b013a278ca1323f9241d85765 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:15:33 +0200 Subject: [PATCH] Move overkiz water heater definitions (#125756) --- .../overkiz/water_heater/__init__.py | 57 +++++++++++++++++++ ...stic_hot_water_production_mlb_component.py | 0 .../atlantic_pass_apc_dhw.py | 0 .../domestic_hot_water_production.py | 0 .../hitachi_dhw.py | 0 .../overkiz/water_heater_entities/__init__.py | 20 ------- 6 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 homeassistant/components/overkiz/water_heater/__init__.py rename homeassistant/components/overkiz/{water_heater_entities => water_heater}/atlantic_domestic_hot_water_production_mlb_component.py (100%) rename homeassistant/components/overkiz/{water_heater_entities => water_heater}/atlantic_pass_apc_dhw.py (100%) rename homeassistant/components/overkiz/{water_heater_entities => water_heater}/domestic_hot_water_production.py (100%) rename homeassistant/components/overkiz/{water_heater_entities => water_heater}/hitachi_dhw.py (100%) delete mode 100644 homeassistant/components/overkiz/water_heater_entities/__init__.py diff --git a/homeassistant/components/overkiz/water_heater/__init__.py b/homeassistant/components/overkiz/water_heater/__init__.py new file mode 100644 index 00000000000..1fb5e5696bd --- /dev/null +++ b/homeassistant/components/overkiz/water_heater/__init__.py @@ -0,0 +1,57 @@ +"""Support for Overkiz water heater devices.""" + +from __future__ import annotations + +from pyoverkiz.enums.ui import UIWidget + +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 ..entity import OverkizEntity +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 + + +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] + entities: list[OverkizEntity] = [] + + 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) + + +WIDGET_TO_WATER_HEATER_ENTITY = { + UIWidget.ATLANTIC_PASS_APC_DHW: AtlanticPassAPCDHW, + UIWidget.DOMESTIC_HOT_WATER_PRODUCTION: DomesticHotWaterProduction, + UIWidget.HITACHI_DHW: HitachiDHW, +} + +CONTROLLABLE_NAME_TO_WATER_HEATER_ENTITY = { + "modbuslink:AtlanticDomesticHotWaterProductionMBLComponent": AtlanticDomesticHotWaterProductionMBLComponent, +} diff --git a/homeassistant/components/overkiz/water_heater_entities/atlantic_domestic_hot_water_production_mlb_component.py b/homeassistant/components/overkiz/water_heater/atlantic_domestic_hot_water_production_mlb_component.py similarity index 100% rename from homeassistant/components/overkiz/water_heater_entities/atlantic_domestic_hot_water_production_mlb_component.py rename to homeassistant/components/overkiz/water_heater/atlantic_domestic_hot_water_production_mlb_component.py diff --git a/homeassistant/components/overkiz/water_heater_entities/atlantic_pass_apc_dhw.py b/homeassistant/components/overkiz/water_heater/atlantic_pass_apc_dhw.py similarity index 100% rename from homeassistant/components/overkiz/water_heater_entities/atlantic_pass_apc_dhw.py rename to homeassistant/components/overkiz/water_heater/atlantic_pass_apc_dhw.py diff --git a/homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py b/homeassistant/components/overkiz/water_heater/domestic_hot_water_production.py similarity index 100% rename from homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py rename to homeassistant/components/overkiz/water_heater/domestic_hot_water_production.py diff --git a/homeassistant/components/overkiz/water_heater_entities/hitachi_dhw.py b/homeassistant/components/overkiz/water_heater/hitachi_dhw.py similarity index 100% rename from homeassistant/components/overkiz/water_heater_entities/hitachi_dhw.py rename to homeassistant/components/overkiz/water_heater/hitachi_dhw.py diff --git a/homeassistant/components/overkiz/water_heater_entities/__init__.py b/homeassistant/components/overkiz/water_heater_entities/__init__.py deleted file mode 100644 index fdc41f213c6..00000000000 --- a/homeassistant/components/overkiz/water_heater_entities/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -"""Water heater entities for the Overkiz (by Somfy) integration.""" - -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 - -WIDGET_TO_WATER_HEATER_ENTITY = { - UIWidget.ATLANTIC_PASS_APC_DHW: AtlanticPassAPCDHW, - UIWidget.DOMESTIC_HOT_WATER_PRODUCTION: DomesticHotWaterProduction, - UIWidget.HITACHI_DHW: HitachiDHW, -} - -CONTROLLABLE_NAME_TO_WATER_HEATER_ENTITY = { - "modbuslink:AtlanticDomesticHotWaterProductionMBLComponent": AtlanticDomesticHotWaterProductionMBLComponent, -}