Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Entity representing a YouTube account."""
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 ATTR_TITLE, DOMAIN, MANUFACTURER
10 from .coordinator import YouTubeDataUpdateCoordinator
11 
12 
13 class YouTubeChannelEntity(CoordinatorEntity[YouTubeDataUpdateCoordinator]):
14  """An HA implementation for YouTube entity."""
15 
16  _attr_has_entity_name = True
17 
18  def __init__(
19  self,
20  coordinator: YouTubeDataUpdateCoordinator,
21  description: EntityDescription,
22  channel_id: str,
23  ) -> None:
24  """Initialize a YouTube entity."""
25  super().__init__(coordinator)
26  self.entity_descriptionentity_description = description
27  self._attr_unique_id_attr_unique_id = (
28  f"{coordinator.config_entry.entry_id}_{channel_id}_{description.key}"
29  )
30  self._channel_id_channel_id = channel_id
31  self._attr_device_info_attr_device_info = DeviceInfo(
32  entry_type=DeviceEntryType.SERVICE,
33  identifiers={(DOMAIN, f"{coordinator.config_entry.entry_id}_{channel_id}")},
34  manufacturer=MANUFACTURER,
35  name=coordinator.data[channel_id][ATTR_TITLE],
36  )
None __init__(self, YouTubeDataUpdateCoordinator coordinator, EntityDescription description, str channel_id)
Definition: entity.py:23