Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """MicroBot class."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
8  PassiveBluetoothCoordinatorEntity,
9 )
10 from homeassistant.helpers import device_registry as dr
11 from homeassistant.helpers.device_registry import DeviceInfo
12 
13 from .const import MANUFACTURER
14 from .coordinator import MicroBotDataUpdateCoordinator
15 
16 
17 class MicroBotEntity(PassiveBluetoothCoordinatorEntity[MicroBotDataUpdateCoordinator]):
18  """Generic entity for all MicroBots."""
19 
20  _attr_has_entity_name = True
21 
22  def __init__(self, coordinator, config_entry):
23  """Initialise the entity."""
24  super().__init__(coordinator)
25  self._address_address = self.coordinator.ble_device.address
26  self._attr_unique_id_attr_unique_id = self._address_address
27  self._attr_device_info_attr_device_info = DeviceInfo(
28  connections={(dr.CONNECTION_BLUETOOTH, self._address_address)},
29  manufacturer=MANUFACTURER,
30  model="Push",
31  name="MicroBot",
32  )
33 
34  @property
35  def data(self) -> dict[str, Any]:
36  """Return coordinator data for this entity."""
37  return self.coordinator.data
def __init__(self, coordinator, config_entry)
Definition: entity.py:22