Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Base entity for Streamlabs integration."""
2 
3 from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN
4 from homeassistant.helpers.device_registry import DeviceInfo
5 from homeassistant.helpers.update_coordinator import CoordinatorEntity
6 
7 from .coordinator import StreamlabsCoordinator, StreamlabsData
8 
9 
10 class StreamlabsWaterEntity(CoordinatorEntity[StreamlabsCoordinator]):
11  """Defines a base Streamlabs entity."""
12 
13  _attr_has_entity_name = True
14 
15  def __init__(
16  self,
17  coordinator: StreamlabsCoordinator,
18  location_id: str,
19  key: str,
20  ) -> None:
21  """Initialize the Streamlabs entity."""
22  super().__init__(coordinator)
23  self._location_id_location_id = location_id
24  self._attr_unique_id_attr_unique_id = f"{location_id}-{key}"
25  self._attr_device_info_attr_device_info = DeviceInfo(
26  identifiers={(HOMEASSISTANT_DOMAIN, location_id)},
27  name=self.location_datalocation_data.name,
28  )
29 
30  @property
31  def location_data(self) -> StreamlabsData:
32  """Returns the data object."""
33  return self.coordinator.data[self._location_id_location_id]
None __init__(self, StreamlabsCoordinator coordinator, str location_id, str key)
Definition: entity.py:20