Move poolsense base entity to its own file (#100981)

This commit is contained in:
Jan-Philipp Benecke 2023-09-27 07:04:20 +02:00 committed by GitHub
parent 4e4d4992bf
commit 009349acf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 18 deletions

View File

@ -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

View File

@ -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}"

View File

@ -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(

View File

@ -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}"

View File

@ -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(