Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Base entity for IronOS integration."""
2 
3 from __future__ import annotations
4 
5 from typing import TYPE_CHECKING
6 
7 from homeassistant.helpers.device_registry import CONNECTION_BLUETOOTH, DeviceInfo
8 from homeassistant.helpers.entity import EntityDescription
9 from homeassistant.helpers.update_coordinator import CoordinatorEntity
10 
11 from .const import MANUFACTURER, MODEL
12 from .coordinator import IronOSLiveDataCoordinator
13 
14 
15 class IronOSBaseEntity(CoordinatorEntity[IronOSLiveDataCoordinator]):
16  """Base IronOS entity."""
17 
18  _attr_has_entity_name = True
19 
20  def __init__(
21  self,
22  coordinator: IronOSLiveDataCoordinator,
23  entity_description: EntityDescription,
24  ) -> None:
25  """Initialize the sensor."""
26  super().__init__(coordinator)
27 
28  self.entity_descriptionentity_description = entity_description
29  self._attr_unique_id_attr_unique_id = (
30  f"{coordinator.config_entry.unique_id}_{entity_description.key}"
31  )
32  if TYPE_CHECKING:
33  assert coordinator.config_entry.unique_id
35  connections={(CONNECTION_BLUETOOTH, coordinator.config_entry.unique_id)},
36  manufacturer=MANUFACTURER,
37  model=MODEL,
38  name="Pinecil",
39  sw_version=coordinator.device_info.build,
40  serial_number=f"{coordinator.device_info.device_sn} (ID:{coordinator.device_info.device_id})",
41  )
None __init__(self, IronOSLiveDataCoordinator coordinator, EntityDescription entity_description)
Definition: entity.py:24