Skip to content

Commit ba69301

Browse files
authored
Move available property to entity.py for Squeezebox (home-assistant#146531)
1 parent 724c349 commit ba69301

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

homeassistant/components/squeezebox/button.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ def __init__(
153153
f"{format_mac(self._player.player_id)}_{entity_description.key}"
154154
)
155155

156-
@property
157-
def available(self) -> bool:
158-
"""Return True if entity is available."""
159-
return self.coordinator.available and super().available
160-
161156
async def async_press(self) -> None:
162157
"""Execute the button action."""
163158
await self._player.async_query("button", self.entity_description.press_action)

homeassistant/components/squeezebox/entity.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ def __init__(self, coordinator: SqueezeBoxPlayerUpdateCoordinator) -> None:
3333
manufacturer=self._player.creator,
3434
)
3535

36+
@property
37+
def available(self) -> bool:
38+
"""Return True if entity is available."""
39+
# super().available refers to CoordinatorEntity.available (self.coordinator.last_update_success)
40+
# self.coordinator.available is the custom availability flag from SqueezeBoxPlayerUpdateCoordinator
41+
return self.coordinator.available and super().available
42+
3643

3744
class LMSStatusEntity(CoordinatorEntity[LMSStatusDataUpdateCoordinator]):
3845
"""Defines a base status sensor entity."""

homeassistant/components/squeezebox/media_player.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,6 @@ def browse_limit(self) -> int:
246246
CONF_BROWSE_LIMIT, DEFAULT_BROWSE_LIMIT
247247
)
248248

249-
@property
250-
def available(self) -> bool:
251-
"""Return True if entity is available."""
252-
return self.coordinator.available and super().available
253-
254249
@property
255250
def extra_state_attributes(self) -> dict[str, Any]:
256251
"""Return device-specific attributes."""

0 commit comments

Comments
 (0)