Remove split devices from HMIPC (#42348)
This commit is contained in:
parent
396f75b4c3
commit
9a970cfe3d
4 changed files with 9 additions and 63 deletions
|
@ -43,7 +43,6 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
|
||||
from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
|
||||
from .generic_entity import async_add_base_multi_area_device
|
||||
from .hap import HomematicipHAP
|
||||
|
||||
ATTR_ACCELERATION_SENSOR_MODE = "acceleration_sensor_mode"
|
||||
|
@ -88,12 +87,9 @@ async def async_setup_entry(
|
|||
if isinstance(device, AsyncTiltVibrationSensor):
|
||||
entities.append(HomematicipTiltVibrationSensor(hap, device))
|
||||
if isinstance(device, AsyncWiredInput32):
|
||||
await async_add_base_multi_area_device(hass, config_entry, device)
|
||||
for channel in range(1, 33):
|
||||
entities.append(
|
||||
HomematicipMultiContactInterface(
|
||||
hap, device, channel=channel, is_multi_area=True
|
||||
)
|
||||
HomematicipMultiContactInterface(hap, device, channel=channel)
|
||||
)
|
||||
elif isinstance(
|
||||
device, (AsyncContactInterface, AsyncFullFlushContactInterface)
|
||||
|
@ -220,11 +216,9 @@ class HomematicipTiltVibrationSensor(HomematicipBaseActionSensor):
|
|||
class HomematicipMultiContactInterface(HomematicipGenericEntity, BinarySensorEntity):
|
||||
"""Representation of the HomematicIP multi room/area contact interface."""
|
||||
|
||||
def __init__(
|
||||
self, hap: HomematicipHAP, device, channel: int, is_multi_area: bool = False
|
||||
) -> None:
|
||||
def __init__(self, hap: HomematicipHAP, device, channel: int) -> None:
|
||||
"""Initialize the multi contact entity."""
|
||||
super().__init__(hap, device, channel=channel, is_multi_area=is_multi_area)
|
||||
super().__init__(hap, device, channel=channel)
|
||||
|
||||
@property
|
||||
def device_class(self) -> str:
|
||||
|
|
|
@ -5,11 +5,9 @@ from typing import Any, Dict, Optional
|
|||
from homematicip.aio.device import AsyncDevice
|
||||
from homematicip.aio.group import AsyncGroup
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
|
||||
from .const import DOMAIN as HMIPC_DOMAIN
|
||||
from .hap import HomematicipHAP
|
||||
|
@ -78,7 +76,6 @@ class HomematicipGenericEntity(Entity):
|
|||
device,
|
||||
post: Optional[str] = None,
|
||||
channel: Optional[int] = None,
|
||||
is_multi_area: Optional[bool] = False,
|
||||
) -> None:
|
||||
"""Initialize the generic entity."""
|
||||
self._hap = hap
|
||||
|
@ -86,7 +83,6 @@ class HomematicipGenericEntity(Entity):
|
|||
self._device = device
|
||||
self._post = post
|
||||
self._channel = channel
|
||||
self._is_multi_area = is_multi_area
|
||||
# Marker showing that the HmIP device hase been removed.
|
||||
self.hmip_device_removed = False
|
||||
_LOGGER.info("Setting up %s (%s)", self.name, self._device.modelType)
|
||||
|
@ -96,20 +92,6 @@ class HomematicipGenericEntity(Entity):
|
|||
"""Return device specific attributes."""
|
||||
# Only physical devices should be HA devices.
|
||||
if isinstance(self._device, AsyncDevice):
|
||||
if self._is_multi_area:
|
||||
return {
|
||||
"identifiers": {
|
||||
# Unique ID of Homematic IP device
|
||||
(HMIPC_DOMAIN, self.unique_id)
|
||||
},
|
||||
"name": self.name,
|
||||
"manufacturer": self._device.oem,
|
||||
"model": self._device.modelType,
|
||||
"sw_version": self._device.firmwareVersion,
|
||||
# Link to the base device.
|
||||
"via_device": (HMIPC_DOMAIN, self._device.id),
|
||||
}
|
||||
|
||||
return {
|
||||
"identifiers": {
|
||||
# Serial numbers of Homematic IP device
|
||||
|
@ -269,19 +251,3 @@ class HomematicipGenericEntity(Entity):
|
|||
state_attr[ATTR_IS_GROUP] = True
|
||||
|
||||
return state_attr
|
||||
|
||||
|
||||
async def async_add_base_multi_area_device(
|
||||
hass: HomeAssistantType, entry: ConfigEntry, device: AsyncDevice
|
||||
):
|
||||
"""Register base multi area device in registry."""
|
||||
device_registry = await dr.async_get_registry(hass)
|
||||
device_registry.async_get_or_create(
|
||||
config_entry_id=entry.entry_id,
|
||||
identifiers={(HMIPC_DOMAIN, device.id)},
|
||||
manufacturer=device.oem,
|
||||
name=device.label,
|
||||
model=device.modelType,
|
||||
sw_version=device.firmwareVersion,
|
||||
via_device=(HMIPC_DOMAIN, device.homeId),
|
||||
)
|
||||
|
|
|
@ -21,10 +21,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
|
||||
from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
|
||||
from .generic_entity import (
|
||||
ATTR_GROUP_MEMBER_UNREACHABLE,
|
||||
async_add_base_multi_area_device,
|
||||
)
|
||||
from .generic_entity import ATTR_GROUP_MEMBER_UNREACHABLE
|
||||
from .hap import HomematicipHAP
|
||||
|
||||
|
||||
|
@ -45,13 +42,8 @@ async def async_setup_entry(
|
|||
):
|
||||
entities.append(HomematicipSwitchMeasuring(hap, device))
|
||||
elif isinstance(device, AsyncWiredSwitch8):
|
||||
await async_add_base_multi_area_device(hass, config_entry, device)
|
||||
for channel in range(1, 9):
|
||||
entities.append(
|
||||
HomematicipMultiSwitch(
|
||||
hap, device, channel=channel, is_multi_area=True
|
||||
)
|
||||
)
|
||||
entities.append(HomematicipMultiSwitch(hap, device, channel=channel))
|
||||
elif isinstance(
|
||||
device,
|
||||
(
|
||||
|
@ -85,11 +77,9 @@ async def async_setup_entry(
|
|||
class HomematicipMultiSwitch(HomematicipGenericEntity, SwitchEntity):
|
||||
"""Representation of the HomematicIP multi switch."""
|
||||
|
||||
def __init__(
|
||||
self, hap: HomematicipHAP, device, channel: int, is_multi_area: bool = False
|
||||
) -> None:
|
||||
def __init__(self, hap: HomematicipHAP, device, channel: int) -> None:
|
||||
"""Initialize the multi switch device."""
|
||||
super().__init__(hap, device, channel=channel, is_multi_area=is_multi_area)
|
||||
super().__init__(hap, device, channel=channel)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
|
|
|
@ -264,12 +264,8 @@ async def test_hmip_multi_area_device(hass, default_mock_hap_factory):
|
|||
# get the device
|
||||
device_registry = await dr.async_get_registry(hass)
|
||||
device = device_registry.async_get(entity.device_id)
|
||||
assert device.name == entity_name
|
||||
|
||||
# get the base device
|
||||
via_device = device_registry.async_get(device.via_device_id)
|
||||
assert via_device.name == "Wired Eingangsmodul – 32-fach"
|
||||
assert device.name == "Wired Eingangsmodul – 32-fach"
|
||||
|
||||
# get the hap
|
||||
hap_device = device_registry.async_get(via_device.via_device_id)
|
||||
hap_device = device_registry.async_get(device.via_device_id)
|
||||
assert hap_device.name == "Access Point"
|
||||
|
|
Loading…
Add table
Reference in a new issue