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