Skip to content

Commit

Permalink
Lyric: Properly tie room accessories to the data coordinator (#115902)
Browse files Browse the repository at this point in the history
* properly tie lyric accessories to the data coordinator so sensors recieve updates

* only check for accessories for LCC devices

* revert: meant to give it its own branch and PR
  • Loading branch information
Ryan Mattson authored Aug 2, 2024
1 parent fb76e70 commit db238a7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
22 changes: 18 additions & 4 deletions homeassistant/components/lyric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def __init__(
) -> None:
"""Initialize the Honeywell Lyric accessory entity."""
super().__init__(coordinator, location, device, key)
self._room = room
self._accessory = accessory
self._room_id = room.id
self._accessory_id = accessory.id

@property
def device_info(self) -> DeviceInfo:
Expand All @@ -202,11 +202,25 @@ def device_info(self) -> DeviceInfo:
identifiers={
(
f"{dr.CONNECTION_NETWORK_MAC}_room_accessory",
f"{self._mac_id}_room{self._room.id}_accessory{self._accessory.id}",
f"{self._mac_id}_room{self._room_id}_accessory{self._accessory_id}",
)
},
manufacturer="Honeywell",
model="RCHTSENSOR",
name=f"{self._room.roomName} Sensor",
name=f"{self.room.roomName} Sensor",
via_device=(dr.CONNECTION_NETWORK_MAC, self._mac_id),
)

@property
def room(self) -> LyricRoom:
"""Get the Lyric Device."""
return self.coordinator.data.rooms_dict[self._mac_id][self._room_id]

@property
def accessory(self) -> LyricAccessories:
"""Get the Lyric Device."""
return next(
accessory
for accessory in self.room.accessories
if accessory.id == self._accessory_id
)
3 changes: 1 addition & 2 deletions homeassistant/components/lyric/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ def __init__(
accessory,
f"{parentDevice.macID}_room{room.id}_acc{accessory.id}_{description.key}",
)
self.room = room
self.entity_description = description
if description.device_class == SensorDeviceClass.TEMPERATURE:
if parentDevice.units == "Fahrenheit":
Expand All @@ -255,4 +254,4 @@ def __init__(
@property
def native_value(self) -> StateType | datetime:
"""Return the state."""
return self.entity_description.value_fn(self._room, self._accessory)
return self.entity_description.value_fn(self.room, self.accessory)

0 comments on commit db238a7

Please sign in to comment.