mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Move lidarr base entity to separate module (#126492)
This commit is contained in:
parent
acd3b2d732
commit
da3f18839a
@ -12,17 +12,13 @@ from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL, Platfor
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||
|
||||
from .const import DEFAULT_NAME, DOMAIN
|
||||
from .coordinator import (
|
||||
DiskSpaceDataUpdateCoordinator,
|
||||
LidarrDataUpdateCoordinator,
|
||||
QueueDataUpdateCoordinator,
|
||||
StatusDataUpdateCoordinator,
|
||||
T,
|
||||
WantedDataUpdateCoordinator,
|
||||
)
|
||||
|
||||
@ -80,22 +76,3 @@ async def async_setup_entry(hass: HomeAssistant, entry: LidarrConfigEntry) -> bo
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: LidarrConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
||||
|
||||
class LidarrEntity(CoordinatorEntity[LidarrDataUpdateCoordinator[T]]):
|
||||
"""Defines a base Lidarr entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: LidarrDataUpdateCoordinator[T],
|
||||
description: EntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the Lidarr entity."""
|
||||
super().__init__(coordinator)
|
||||
self.entity_description = description
|
||||
self._attr_unique_id = f"{coordinator.config_entry.entry_id}_{description.key}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, coordinator.config_entry.entry_id)}
|
||||
)
|
||||
|
29
homeassistant/components/lidarr/entity.py
Normal file
29
homeassistant/components/lidarr/entity.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""The Lidarr component."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import LidarrDataUpdateCoordinator, T
|
||||
|
||||
|
||||
class LidarrEntity(CoordinatorEntity[LidarrDataUpdateCoordinator[T]]):
|
||||
"""Defines a base Lidarr entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: LidarrDataUpdateCoordinator[T],
|
||||
description: EntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the Lidarr entity."""
|
||||
super().__init__(coordinator)
|
||||
self.entity_description = description
|
||||
self._attr_unique_id = f"{coordinator.config_entry.entry_id}_{description.key}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, coordinator.config_entry.entry_id)}
|
||||
)
|
@ -18,9 +18,10 @@ from homeassistant.const import UnitOfInformation
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import LidarrConfigEntry, LidarrEntity
|
||||
from . import LidarrConfigEntry
|
||||
from .const import BYTE_SIZES
|
||||
from .coordinator import LidarrDataUpdateCoordinator, T
|
||||
from .entity import LidarrEntity
|
||||
|
||||
|
||||
def get_space(data: list[LidarrRootFolder], name: str) -> str:
|
||||
|
Loading…
x
Reference in New Issue
Block a user