Move available property to entity.py for Squeezebox (#146531)

This commit is contained in:
peteS-UK 2025-06-11 15:34:08 +01:00 committed by GitHub
parent 724c349194
commit ba69301dda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 10 deletions

View File

@ -153,11 +153,6 @@ class SqueezeboxButtonEntity(SqueezeboxEntity, ButtonEntity):
f"{format_mac(self._player.player_id)}_{entity_description.key}"
)
@property
def available(self) -> bool:
"""Return True if entity is available."""
return self.coordinator.available and super().available
async def async_press(self) -> None:
"""Execute the button action."""
await self._player.async_query("button", self.entity_description.press_action)

View File

@ -33,6 +33,13 @@ class SqueezeboxEntity(CoordinatorEntity[SqueezeBoxPlayerUpdateCoordinator]):
manufacturer=self._player.creator,
)
@property
def available(self) -> bool:
"""Return True if entity is available."""
# super().available refers to CoordinatorEntity.available (self.coordinator.last_update_success)
# self.coordinator.available is the custom availability flag from SqueezeBoxPlayerUpdateCoordinator
return self.coordinator.available and super().available
class LMSStatusEntity(CoordinatorEntity[LMSStatusDataUpdateCoordinator]):
"""Defines a base status sensor entity."""

View File

@ -246,11 +246,6 @@ class SqueezeBoxMediaPlayerEntity(SqueezeboxEntity, MediaPlayerEntity):
CONF_BROWSE_LIMIT, DEFAULT_BROWSE_LIMIT
)
@property
def available(self) -> bool:
"""Return True if entity is available."""
return self.coordinator.available and super().available
@property
def extra_state_attributes(self) -> dict[str, Any]:
"""Return device-specific attributes."""