Skip to content

Commit

Permalink
Merge pull request #49 from rmassch/rmassch/issue47
Browse files Browse the repository at this point in the history
Rmassch/issue47
  • Loading branch information
rmassch authored Jun 17, 2023
2 parents ef5afe5 + d9c1b88 commit c3c4189
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions custom_components/healthbox/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)


from .const import DOMAIN, MANUFACTURER, HealthboxRoom
from .const import DOMAIN, MANUFACTURER, HealthboxRoom, LOGGER
from .coordinator import HealthboxDataUpdateCoordinator


Expand Down Expand Up @@ -330,6 +330,17 @@ def __init__(
@property
def native_value(self) -> float | int | str | Decimal:
"""Sensor native value."""
return self.entity_description.value_fn(
self.coordinator.api.rooms[int(self.entity_description.room.room_id) - 1]
)
room_id: int = int(self.entity_description.room.room_id)

matching_room = [
room for room in self.coordinator.api.rooms if int(room.room_id) == room_id
]

if len(matching_room) != 1:
error_msg: str = f"No matching room found for id {room_id}"
LOGGER.error(error_msg)
else:
matching_room = matching_room[0]
return self.entity_description.value_fn(matching_room)

return None

0 comments on commit c3c4189

Please sign in to comment.