Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Base Entity for Sonarr."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
6 from homeassistant.helpers.entity import EntityDescription
7 from homeassistant.helpers.update_coordinator import CoordinatorEntity
8 
9 from .const import DEFAULT_NAME, DOMAIN
10 from .coordinator import SonarrDataT, SonarrDataUpdateCoordinator
11 
12 
13 class SonarrEntity(CoordinatorEntity[SonarrDataUpdateCoordinator[SonarrDataT]]):
14  """Defines a base Sonarr entity."""
15 
16  _attr_has_entity_name = True
17 
18  def __init__(
19  self,
20  coordinator: SonarrDataUpdateCoordinator[SonarrDataT],
21  description: EntityDescription,
22  ) -> None:
23  """Initialize the Sonarr entity."""
24  super().__init__(coordinator)
25  self.coordinatorcoordinator = coordinator
26  self.entity_descriptionentity_description = description
27  self._attr_unique_id_attr_unique_id = f"{coordinator.config_entry.entry_id}_{description.key}"
28  self._attr_device_info_attr_device_info = DeviceInfo(
29  configuration_url=coordinator.host_configuration.base_url,
30  entry_type=DeviceEntryType.SERVICE,
31  identifiers={(DOMAIN, coordinator.config_entry.entry_id)},
32  manufacturer=DEFAULT_NAME,
33  name=DEFAULT_NAME,
34  sw_version=coordinator.system_version,
35  )
None __init__(self, SonarrDataUpdateCoordinator[SonarrDataT] coordinator, EntityDescription description)
Definition: entity.py:22