mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Move poolsense base entity to its own file (#100981)
This commit is contained in:
parent
4e4d4992bf
commit
009349acf0
@ -979,6 +979,7 @@ omit =
|
|||||||
homeassistant/components/poolsense/__init__.py
|
homeassistant/components/poolsense/__init__.py
|
||||||
homeassistant/components/poolsense/binary_sensor.py
|
homeassistant/components/poolsense/binary_sensor.py
|
||||||
homeassistant/components/poolsense/coordinator.py
|
homeassistant/components/poolsense/coordinator.py
|
||||||
|
homeassistant/components/poolsense/entity.py
|
||||||
homeassistant/components/poolsense/sensor.py
|
homeassistant/components/poolsense/sensor.py
|
||||||
homeassistant/components/powerwall/__init__.py
|
homeassistant/components/powerwall/__init__.py
|
||||||
homeassistant/components/progettihwsw/__init__.py
|
homeassistant/components/progettihwsw/__init__.py
|
||||||
|
@ -7,10 +7,8 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, Platform
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import aiohttp_client
|
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
|
from .coordinator import PoolSenseDataUpdateCoordinator
|
||||||
|
|
||||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||||
@ -51,16 +49,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
return unload_ok
|
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}"
|
|
||||||
|
@ -11,8 +11,8 @@ from homeassistant.const import CONF_EMAIL
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import PoolSenseEntity
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
from .entity import PoolSenseEntity
|
||||||
|
|
||||||
BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
||||||
BinarySensorEntityDescription(
|
BinarySensorEntityDescription(
|
||||||
|
18
homeassistant/components/poolsense/entity.py
Normal file
18
homeassistant/components/poolsense/entity.py
Normal 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}"
|
@ -16,8 +16,8 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import PoolSenseEntity
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
from .entity import PoolSenseEntity
|
||||||
|
|
||||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user