diff --git a/.coveragerc b/.coveragerc index f6f76f5db51..e24a974ef85 100644 --- a/.coveragerc +++ b/.coveragerc @@ -979,6 +979,7 @@ omit = homeassistant/components/poolsense/__init__.py homeassistant/components/poolsense/binary_sensor.py homeassistant/components/poolsense/coordinator.py + homeassistant/components/poolsense/entity.py homeassistant/components/poolsense/sensor.py homeassistant/components/powerwall/__init__.py homeassistant/components/progettihwsw/__init__.py diff --git a/homeassistant/components/poolsense/__init__.py b/homeassistant/components/poolsense/__init__.py index 1eccc8b455b..644ecb8cf3d 100644 --- a/homeassistant/components/poolsense/__init__.py +++ b/homeassistant/components/poolsense/__init__.py @@ -7,10 +7,8 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import aiohttp_client -from homeassistant.helpers.entity import EntityDescription -from homeassistant.helpers.update_coordinator import CoordinatorEntity -from .const import ATTRIBUTION, DOMAIN +from .const import DOMAIN from .coordinator import PoolSenseDataUpdateCoordinator PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR] @@ -51,16 +49,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if unload_ok: hass.data[DOMAIN].pop(entry.entry_id) return unload_ok - - -class PoolSenseEntity(CoordinatorEntity): - """Implements a common class elements representing the PoolSense component.""" - - _attr_attribution = ATTRIBUTION - - def __init__(self, coordinator, email, description: EntityDescription) -> None: - """Initialize poolsense sensor.""" - super().__init__(coordinator) - self.entity_description = description - self._attr_name = f"PoolSense {description.name}" - self._attr_unique_id = f"{email}-{description.key}" diff --git a/homeassistant/components/poolsense/binary_sensor.py b/homeassistant/components/poolsense/binary_sensor.py index e206521c3d9..56e417511bd 100644 --- a/homeassistant/components/poolsense/binary_sensor.py +++ b/homeassistant/components/poolsense/binary_sensor.py @@ -11,8 +11,8 @@ from homeassistant.const import CONF_EMAIL from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from . import PoolSenseEntity from .const import DOMAIN +from .entity import PoolSenseEntity BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = ( BinarySensorEntityDescription( diff --git a/homeassistant/components/poolsense/entity.py b/homeassistant/components/poolsense/entity.py new file mode 100644 index 00000000000..2186d815135 --- /dev/null +++ b/homeassistant/components/poolsense/entity.py @@ -0,0 +1,18 @@ +"""Base entity for poolsense integration.""" +from homeassistant.helpers.entity import EntityDescription +from homeassistant.helpers.update_coordinator import CoordinatorEntity + +from .const import ATTRIBUTION + + +class PoolSenseEntity(CoordinatorEntity): + """Implements a common class elements representing the PoolSense component.""" + + _attr_attribution = ATTRIBUTION + + def __init__(self, coordinator, email, description: EntityDescription) -> None: + """Initialize poolsense sensor.""" + super().__init__(coordinator) + self.entity_description = description + self._attr_name = f"PoolSense {description.name}" + self._attr_unique_id = f"{email}-{description.key}" diff --git a/homeassistant/components/poolsense/sensor.py b/homeassistant/components/poolsense/sensor.py index fe3535b378f..eee7518e6da 100644 --- a/homeassistant/components/poolsense/sensor.py +++ b/homeassistant/components/poolsense/sensor.py @@ -16,8 +16,8 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from . import PoolSenseEntity from .const import DOMAIN +from .entity import PoolSenseEntity SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription(