Improve type hints in media player state (#82845)
* Improve type hints in media player state * Reduce size of PR
This commit is contained in:
parent
effa9940ff
commit
42701a6872
4 changed files with 6 additions and 5 deletions
|
@ -413,7 +413,7 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
|||
return self._source_manager.source_list
|
||||
|
||||
@property
|
||||
def state(self) -> str:
|
||||
def state(self) -> MediaPlayerState:
|
||||
"""State of the player."""
|
||||
return PLAY_STATE_TO_STATE[self._player.state]
|
||||
|
||||
|
|
|
@ -126,13 +126,14 @@ class RussoundZoneDevice(MediaPlayerEntity):
|
|||
return self._zone_var("name", self._name)
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
def state(self) -> MediaPlayerState | None:
|
||||
"""Return the state of the device."""
|
||||
status = self._zone_var("status", "OFF")
|
||||
if status == "ON":
|
||||
return MediaPlayerState.ON
|
||||
if status == "OFF":
|
||||
return MediaPlayerState.OFF
|
||||
return None
|
||||
|
||||
@property
|
||||
def source(self):
|
||||
|
|
|
@ -43,7 +43,7 @@ SUPPORT_XBOX = (
|
|||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
)
|
||||
|
||||
XBOX_STATE_MAP = {
|
||||
XBOX_STATE_MAP: dict[PlaybackState | PowerState, MediaPlayerState | None] = {
|
||||
PlaybackState.Playing: MediaPlayerState.PLAYING,
|
||||
PlaybackState.Paused: MediaPlayerState.PAUSED,
|
||||
PowerState.On: MediaPlayerState.ON,
|
||||
|
@ -99,7 +99,7 @@ class XboxMediaPlayer(CoordinatorEntity[XboxUpdateCoordinator], MediaPlayerEntit
|
|||
return self.coordinator.data.consoles[self._console.id]
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
def state(self) -> MediaPlayerState | None:
|
||||
"""State of the player."""
|
||||
status = self.data.status
|
||||
if status.playback_state in XBOX_STATE_MAP:
|
||||
|
|
|
@ -145,7 +145,7 @@ class MusicCastMediaPlayer(MusicCastDeviceEntity, MediaPlayerEntity):
|
|||
return None
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
def state(self) -> MediaPlayerState:
|
||||
"""Return the state of the player."""
|
||||
if self.coordinator.data.zones[self._zone_id].power == "on":
|
||||
if self._is_netusb and self.coordinator.data.netusb_playback == "pause":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue