Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """The Honeywell Lyric integration."""
2 
3 from __future__ import annotations
4 
5 from aiolyric import Lyric
6 from aiolyric.objects.device import LyricDevice
7 from aiolyric.objects.location import LyricLocation
8 from aiolyric.objects.priority import LyricAccessory, LyricRoom
9 
10 from homeassistant.helpers import device_registry as dr
11 from homeassistant.helpers.device_registry import DeviceInfo
13  CoordinatorEntity,
14  DataUpdateCoordinator,
15 )
16 
17 
18 class LyricEntity(CoordinatorEntity[DataUpdateCoordinator[Lyric]]):
19  """Defines a base Honeywell Lyric entity."""
20 
21  _attr_has_entity_name = True
22 
23  def __init__(
24  self,
25  coordinator: DataUpdateCoordinator[Lyric],
26  location: LyricLocation,
27  device: LyricDevice,
28  key: str,
29  ) -> None:
30  """Initialize the Honeywell Lyric entity."""
31  super().__init__(coordinator)
32  self._key_key = key
33  self._location_location = location
34  self._mac_id_mac_id = device.mac_id
35  self._update_thermostat_update_thermostat = coordinator.data.update_thermostat
36  self._update_fan_update_fan = coordinator.data.update_fan
37 
38  @property
39  def unique_id(self) -> str:
40  """Return the unique ID for this entity."""
41  return self._key_key
42 
43  @property
44  def location(self) -> LyricLocation:
45  """Get the Lyric Location."""
46  return self.coordinator.data.locations_dict[self._location_location.location_id]
47 
48  @property
49  def device(self) -> LyricDevice:
50  """Get the Lyric Device."""
51  return self.locationlocation.devices_dict[self._mac_id_mac_id]
52 
53 
55  """Defines a Honeywell Lyric device entity."""
56 
57  @property
58  def device_info(self) -> DeviceInfo:
59  """Return device information about this Honeywell Lyric instance."""
60  return DeviceInfo(
61  identifiers={(dr.CONNECTION_NETWORK_MAC, self._mac_id_mac_id)},
62  connections={(dr.CONNECTION_NETWORK_MAC, self._mac_id_mac_id)},
63  manufacturer="Honeywell",
64  model=self.devicedevice.device_model,
65  name=f"{self.device.name} Thermostat",
66  )
67 
68 
70  """Defines a Honeywell Lyric accessory entity, a sub-device of a thermostat."""
71 
72  def __init__(
73  self,
74  coordinator: DataUpdateCoordinator[Lyric],
75  location: LyricLocation,
76  device: LyricDevice,
77  room: LyricRoom,
78  accessory: LyricAccessory,
79  key: str,
80  ) -> None:
81  """Initialize the Honeywell Lyric accessory entity."""
82  super().__init__(coordinator, location, device, key)
83  self._room_id_room_id = room.id
84  self._accessory_id_accessory_id = accessory.id
85 
86  @property
87  def device_info(self) -> DeviceInfo:
88  """Return device information about this Honeywell Lyric instance."""
89  return DeviceInfo(
90  identifiers={
91  (
92  f"{dr.CONNECTION_NETWORK_MAC}_room_accessory",
93  f"{self._mac_id}_room{self._room_id}_accessory{self._accessory_id}",
94  )
95  },
96  manufacturer="Honeywell",
97  model="RCHTSENSOR",
98  name=f"{self.room.room_name} Sensor",
99  via_device=(dr.CONNECTION_NETWORK_MAC, self._mac_id_mac_id),
100  )
101 
102  @property
103  def room(self) -> LyricRoom:
104  """Get the Lyric Device."""
105  return self.coordinator.data.rooms_dict[self._mac_id_mac_id][self._room_id_room_id]
106 
107  @property
108  def accessory(self) -> LyricAccessory:
109  """Get the Lyric Device."""
110  return next(
111  accessory
112  for accessory in self.roomroom.accessories
113  if accessory.id == self._accessory_id_accessory_id
114  )
None __init__(self, DataUpdateCoordinator[Lyric] coordinator, LyricLocation location, LyricDevice device, LyricRoom room, LyricAccessory accessory, str key)
Definition: entity.py:80
None __init__(self, DataUpdateCoordinator[Lyric] coordinator, LyricLocation location, LyricDevice device, str key)
Definition: entity.py:29