diff --git a/homeassistant/components/lyric/__init__.py b/homeassistant/components/lyric/__init__.py index 7c002229741..e1eaed6602c 100644 --- a/homeassistant/components/lyric/__init__.py +++ b/homeassistant/components/lyric/__init__.py @@ -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 + ) diff --git a/homeassistant/components/lyric/sensor.py b/homeassistant/components/lyric/sensor.py index 64f60fa6611..9f05354c399 100644 --- a/homeassistant/components/lyric/sensor.py +++ b/homeassistant/components/lyric/sensor.py @@ -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)