Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Provides the DataUpdateCoordinator."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from homeassistant.helpers.entity import EntityDescription
8 from homeassistant.helpers.update_coordinator import CoordinatorEntity
9 
10 from .coordinator import GardenaBluetoothCoordinator
11 
12 
13 class GardenaBluetoothEntity(CoordinatorEntity[GardenaBluetoothCoordinator]):
14  """Coordinator entity for Gardena Bluetooth."""
15 
16  _attr_has_entity_name = True
17 
18  def __init__(
19  self, coordinator: GardenaBluetoothCoordinator, context: Any = None
20  ) -> None:
21  """Initialize coordinator entity."""
22  super().__init__(coordinator, context)
23  self._attr_device_info_attr_device_info = coordinator.device_info
24 
25  @property
26  def available(self) -> bool:
27  """Return if entity is available."""
28  return self.coordinator.last_update_success and self._attr_available
29 
30 
32  """Coordinator entity for entities with entity description."""
33 
34  def __init__(
35  self,
36  coordinator: GardenaBluetoothCoordinator,
37  description: EntityDescription,
38  context: set[str],
39  ) -> None:
40  """Initialize description entity."""
41  super().__init__(coordinator, context)
42  self._attr_unique_id_attr_unique_id = f"{coordinator.address}-{description.key}"
43  self.entity_descriptionentity_description = description
None __init__(self, GardenaBluetoothCoordinator coordinator, EntityDescription description, set[str] context)
Definition: entity.py:39
None __init__(self, GardenaBluetoothCoordinator coordinator, Any context=None)
Definition: entity.py:20