2021-06-11 11:48:20 +00:00
|
|
|
"""Base Entity for Sonarr."""
|
2022-10-07 22:25:16 +00:00
|
|
|
from __future__ import annotations
|
2021-06-11 11:48:20 +00:00
|
|
|
|
2023-08-11 02:04:26 +00:00
|
|
|
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
|
|
|
from homeassistant.helpers.entity import EntityDescription
|
2022-10-07 22:25:16 +00:00
|
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
2021-06-11 11:48:20 +00:00
|
|
|
|
2022-10-08 01:53:48 +00:00
|
|
|
from .const import DEFAULT_NAME, DOMAIN
|
2022-10-07 22:25:16 +00:00
|
|
|
from .coordinator import SonarrDataT, SonarrDataUpdateCoordinator
|
2021-06-11 11:48:20 +00:00
|
|
|
|
|
|
|
|
2022-10-07 22:25:16 +00:00
|
|
|
class SonarrEntity(CoordinatorEntity[SonarrDataUpdateCoordinator[SonarrDataT]]):
|
2021-06-11 11:48:20 +00:00
|
|
|
"""Defines a base Sonarr entity."""
|
|
|
|
|
2022-10-08 01:53:48 +00:00
|
|
|
_attr_has_entity_name = True
|
|
|
|
|
2021-06-11 11:48:20 +00:00
|
|
|
def __init__(
|
|
|
|
self,
|
2022-10-07 22:25:16 +00:00
|
|
|
coordinator: SonarrDataUpdateCoordinator[SonarrDataT],
|
|
|
|
description: EntityDescription,
|
2021-06-11 11:48:20 +00:00
|
|
|
) -> None:
|
|
|
|
"""Initialize the Sonarr entity."""
|
2022-10-07 22:25:16 +00:00
|
|
|
super().__init__(coordinator)
|
|
|
|
self.coordinator = coordinator
|
|
|
|
self.entity_description = description
|
|
|
|
self._attr_unique_id = f"{coordinator.config_entry.entry_id}_{description.key}"
|
2023-09-07 17:47:56 +00:00
|
|
|
self._attr_device_info = DeviceInfo(
|
|
|
|
configuration_url=coordinator.host_configuration.base_url,
|
2021-11-22 17:14:15 +00:00
|
|
|
entry_type=DeviceEntryType.SERVICE,
|
2023-09-07 17:47:56 +00:00
|
|
|
identifiers={(DOMAIN, coordinator.config_entry.entry_id)},
|
2022-10-08 01:53:48 +00:00
|
|
|
manufacturer=DEFAULT_NAME,
|
|
|
|
name=DEFAULT_NAME,
|
2023-09-07 17:47:56 +00:00
|
|
|
sw_version=coordinator.system_version,
|
2021-10-22 15:40:13 +00:00
|
|
|
)
|