Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Base entity for the Anova integration."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.helpers.entity import Entity, EntityDescription
6 from homeassistant.helpers.update_coordinator import CoordinatorEntity
7 
8 from .coordinator import AnovaCoordinator
9 
10 
11 class AnovaEntity(CoordinatorEntity[AnovaCoordinator], Entity):
12  """Defines an Anova entity."""
13 
14  _attr_has_entity_name = True
15 
16  def __init__(self, coordinator: AnovaCoordinator) -> None:
17  """Initialize the Anova entity."""
18  super().__init__(coordinator)
19  self.devicedevice = coordinator.anova_device
20  self._attr_device_info_attr_device_info = coordinator.device_info
21 
22  @property
23  def available(self) -> bool:
24  """Return if entity is available."""
25  return self.coordinator.data is not None and super().available
26 
27 
29  """Defines an Anova entity that uses a description."""
30 
31  def __init__(
32  self, coordinator: AnovaCoordinator, description: EntityDescription
33  ) -> None:
34  """Initialize the entity and declare unique id based on description key."""
35  super().__init__(coordinator)
36  self.entity_descriptionentity_description = description
37  self._attr_unique_id_attr_unique_id = f"{coordinator.device_unique_id}_{description.key}"
None __init__(self, AnovaCoordinator coordinator, EntityDescription description)
Definition: entity.py:33
None __init__(self, AnovaCoordinator coordinator)
Definition: entity.py:16