Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Support for Steamist sensors."""
2 
3 from __future__ import annotations
4 
5 from aiosteamist import SteamistStatus
6 
7 from homeassistant.config_entries import ConfigEntry
8 from homeassistant.const import CONF_HOST, CONF_MODEL
9 from homeassistant.helpers import device_registry as dr
10 from homeassistant.helpers.device_registry import DeviceInfo
11 from homeassistant.helpers.entity import Entity, EntityDescription
12 from homeassistant.helpers.update_coordinator import CoordinatorEntity
13 
14 from .coordinator import SteamistDataUpdateCoordinator
15 
16 
17 class SteamistEntity(CoordinatorEntity[SteamistDataUpdateCoordinator], Entity):
18  """Representation of a Steamist entity."""
19 
20  _attr_has_entity_name = True
21 
22  def __init__(
23  self,
24  coordinator: SteamistDataUpdateCoordinator,
25  entry: ConfigEntry,
26  description: EntityDescription,
27  ) -> None:
28  """Initialize the entity."""
29  super().__init__(coordinator)
30  self.entity_descriptionentity_description = description
31  self._attr_unique_id_attr_unique_id = f"{entry.entry_id}_{description.key}"
32  if entry.unique_id: # Only present if UDP broadcast works
33  self._attr_device_info_attr_device_info = DeviceInfo(
34  connections={(dr.CONNECTION_NETWORK_MAC, entry.unique_id)},
35  manufacturer="Steamist",
36  model=entry.data[CONF_MODEL],
37  configuration_url=f"http://{entry.data[CONF_HOST]}",
38  )
39 
40  @property
41  def _status(self) -> SteamistStatus:
42  """Return the steamist status."""
43  return self.coordinator.data
None __init__(self, SteamistDataUpdateCoordinator coordinator, ConfigEntry entry, EntityDescription description)
Definition: entity.py:27