Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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 @@
) -> 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

Check warning on line 196 in homeassistant/components/lyric/__init__.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/lyric/__init__.py#L195-L196

Added lines #L195 - L196 were not covered by tests

@property
def device_info(self) -> DeviceInfo:
Expand All @@ -202,11 +202,25 @@
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]

Check warning on line 217 in homeassistant/components/lyric/__init__.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/lyric/__init__.py#L217

Added line #L217 was not covered by tests

@property
def accessory(self) -> LyricAccessories:
frenck marked this conversation as resolved.
Show resolved Hide resolved
"""Get the Lyric Device."""
return next(

Check warning on line 222 in homeassistant/components/lyric/__init__.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/lyric/__init__.py#L222

Added line #L222 was not covered by tests
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 @@
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 @@
@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)

Check warning on line 257 in homeassistant/components/lyric/sensor.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/lyric/sensor.py#L257

Added line #L257 was not covered by tests