Lyric: Properly tie room accessories to the data coordinator (#115902)

* 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
This commit is contained in:
Ryan Mattson 2024-08-02 08:13:56 -05:00 committed by GitHub
parent fb76e70c3f
commit db238a75e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 6 deletions

View File

@ -192,8 +192,8 @@ class LyricAccessoryEntity(LyricDeviceEntity):
) -> 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:
@ -202,11 +202,25 @@ class LyricAccessoryEntity(LyricDeviceEntity):
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
)

View File

@ -244,7 +244,6 @@ class LyricAccessorySensor(LyricAccessoryEntity, SensorEntity):
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":
@ -255,4 +254,4 @@ class LyricAccessorySensor(LyricAccessoryEntity, SensorEntity):
@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)