Skip to content

Commit

Permalink
Move homematicip_cloud base entity to separate module (home-assistant…
Browse files Browse the repository at this point in the history
…#126094)

* Move homematicip_cloud base entity to separate module

* One more
  • Loading branch information
epenet authored Sep 17, 2024
1 parent a9c479a commit f3facac
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 61 deletions.
3 changes: 1 addition & 2 deletions homeassistant/components/homematicip_cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
HMIPC_HAPID,
HMIPC_NAME,
)
from .generic_entity import HomematicipGenericEntity # noqa: F401
from .hap import HomematicipAuth, HomematicipHAP # noqa: F401
from .hap import HomematicipHAP
from .services import async_setup_services, async_unload_services

CONFIG_SCHEMA = vol.Schema(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import DOMAIN as HMIPC_DOMAIN
from .const import DOMAIN
from .hap import AsyncHome, HomematicipHAP

_LOGGER = logging.getLogger(__name__)
Expand All @@ -35,7 +35,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the HomematicIP alrm control panel from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]
hap = hass.data[DOMAIN][config_entry.unique_id]
async_add_entities([HomematicipAlarmControlPanelEntity(hap)])


Expand All @@ -57,11 +57,11 @@ def __init__(self, hap: HomematicipHAP) -> None:
def device_info(self) -> DeviceInfo:
"""Return device specific attributes."""
return DeviceInfo(
identifiers={(HMIPC_DOMAIN, f"ACP {self._home.id}")},
identifiers={(DOMAIN, f"ACP {self._home.id}")},
manufacturer="eQ-3",
model=CONST_ALARM_CONTROL_PANEL_NAME,
name=self.name,
via_device=(HMIPC_DOMAIN, self._home.id),
via_device=(DOMAIN, self._home.id),
)

@property
Expand Down
7 changes: 4 additions & 3 deletions homeassistant/components/homematicip_cloud/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .const import DOMAIN
from .entity import HomematicipGenericEntity
from .hap import HomematicipHAP

ATTR_ACCELERATION_SENSOR_MODE = "acceleration_sensor_mode"
Expand Down Expand Up @@ -78,7 +79,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the HomematicIP Cloud binary sensor from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]
hap = hass.data[DOMAIN][config_entry.unique_id]
entities: list[HomematicipGenericEntity] = [HomematicipCloudConnectionSensor(hap)]
for device in hap.home.devices:
if isinstance(device, AsyncAccelerationSensor):
Expand Down Expand Up @@ -168,7 +169,7 @@ def device_info(self) -> DeviceInfo:
return DeviceInfo(
identifiers={
# Serial numbers of Homematic IP device
(HMIPC_DOMAIN, self._home.id)
(DOMAIN, self._home.id)
}
)

Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/homematicip_cloud/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .const import DOMAIN
from .entity import HomematicipGenericEntity
from .hap import HomematicipHAP


Expand All @@ -19,7 +20,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the HomematicIP button from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]
hap = hass.data[DOMAIN][config_entry.unique_id]

async_add_entities(
HomematicipGarageDoorControllerButton(hap, device)
Expand Down
9 changes: 5 additions & 4 deletions homeassistant/components/homematicip_cloud/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .const import DOMAIN
from .entity import HomematicipGenericEntity
from .hap import HomematicipHAP

HEATING_PROFILES = {"PROFILE_1": 0, "PROFILE_2": 1, "PROFILE_3": 2}
Expand Down Expand Up @@ -59,7 +60,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the HomematicIP climate from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]
hap = hass.data[DOMAIN][config_entry.unique_id]

async_add_entities(
HomematicipHeatingGroup(hap, device)
Expand Down Expand Up @@ -94,11 +95,11 @@ def __init__(self, hap: HomematicipHAP, device: AsyncHeatingGroup) -> None:
def device_info(self) -> DeviceInfo:
"""Return device specific attributes."""
return DeviceInfo(
identifiers={(HMIPC_DOMAIN, self._device.id)},
identifiers={(DOMAIN, self._device.id)},
manufacturer="eQ-3",
model=self._device.modelType,
name=self._device.label,
via_device=(HMIPC_DOMAIN, self._device.homeId),
via_device=(DOMAIN, self._device.homeId),
)

@property
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/homematicip_cloud/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .const import DOMAIN
from .entity import HomematicipGenericEntity
from .hap import HomematicipHAP

HMIP_COVER_OPEN = 0
Expand All @@ -40,7 +41,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the HomematicIP cover from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]
hap = hass.data[DOMAIN][config_entry.unique_id]
entities: list[HomematicipGenericEntity] = [
HomematicipCoverShutterGroup(hap, group)
for group in hap.home.groups
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity import Entity

from .const import DOMAIN as HMIPC_DOMAIN
from .const import DOMAIN
from .hap import AsyncHome, HomematicipHAP

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -104,14 +104,14 @@ def device_info(self) -> DeviceInfo | None:
return DeviceInfo(
identifiers={
# Serial numbers of Homematic IP device
(HMIPC_DOMAIN, self._device.id)
(DOMAIN, self._device.id)
},
manufacturer=self._device.oem,
model=self._device.modelType,
name=self._device.label,
sw_version=self._device.firmwareVersion,
# Link to the homematic ip access point.
via_device=(HMIPC_DOMAIN, self._device.homeId),
via_device=(DOMAIN, self._device.homeId),
)
return None

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homematicip_cloud/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from homeassistant.exceptions import HomeAssistantError

from . import HomematicipGenericEntity
from .entity import HomematicipGenericEntity

_LOGGER = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/homematicip_cloud/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .const import DOMAIN
from .entity import HomematicipGenericEntity
from .hap import HomematicipHAP


Expand All @@ -40,7 +41,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the HomematicIP Cloud lights from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]
hap = hass.data[DOMAIN][config_entry.unique_id]
entities: list[HomematicipGenericEntity] = []
for device in hap.home.devices:
if isinstance(device, AsyncBrandSwitchMeasuring):
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/homematicip_cloud/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .const import DOMAIN
from .entity import HomematicipGenericEntity
from .helpers import handle_errors

_LOGGER = logging.getLogger(__name__)
Expand All @@ -39,7 +40,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the HomematicIP locks from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]
hap = hass.data[DOMAIN][config_entry.unique_id]

async_add_entities(
HomematicipDoorLockDrive(hap, device)
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/homematicip_cloud/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType

from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .const import DOMAIN
from .entity import HomematicipGenericEntity
from .hap import HomematicipHAP
from .helpers import get_channels_from_device

Expand Down Expand Up @@ -91,7 +92,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the HomematicIP Cloud sensors from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]
hap = hass.data[DOMAIN][config_entry.unique_id]
entities: list[HomematicipGenericEntity] = []
for device in hap.home.devices:
if isinstance(device, AsyncHomeControlAccessPoint):
Expand Down
Loading

0 comments on commit f3facac

Please sign in to comment.