mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
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
@ -413,7 +413,7 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
|||||||
return self._source_manager.source_list
|
return self._source_manager.source_list
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self) -> str:
|
def state(self) -> MediaPlayerState:
|
||||||
"""State of the player."""
|
"""State of the player."""
|
||||||
return PLAY_STATE_TO_STATE[self._player.state]
|
return PLAY_STATE_TO_STATE[self._player.state]
|
||||||
|
|
||||||
|
@ -126,13 +126,14 @@ class RussoundZoneDevice(MediaPlayerEntity):
|
|||||||
return self._zone_var("name", self._name)
|
return self._zone_var("name", self._name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self) -> MediaPlayerState | None:
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
status = self._zone_var("status", "OFF")
|
status = self._zone_var("status", "OFF")
|
||||||
if status == "ON":
|
if status == "ON":
|
||||||
return MediaPlayerState.ON
|
return MediaPlayerState.ON
|
||||||
if status == "OFF":
|
if status == "OFF":
|
||||||
return MediaPlayerState.OFF
|
return MediaPlayerState.OFF
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source(self):
|
def source(self):
|
||||||
|
@ -43,7 +43,7 @@ SUPPORT_XBOX = (
|
|||||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||||
)
|
)
|
||||||
|
|
||||||
XBOX_STATE_MAP = {
|
XBOX_STATE_MAP: dict[PlaybackState | PowerState, MediaPlayerState | None] = {
|
||||||
PlaybackState.Playing: MediaPlayerState.PLAYING,
|
PlaybackState.Playing: MediaPlayerState.PLAYING,
|
||||||
PlaybackState.Paused: MediaPlayerState.PAUSED,
|
PlaybackState.Paused: MediaPlayerState.PAUSED,
|
||||||
PowerState.On: MediaPlayerState.ON,
|
PowerState.On: MediaPlayerState.ON,
|
||||||
@ -99,7 +99,7 @@ class XboxMediaPlayer(CoordinatorEntity[XboxUpdateCoordinator], MediaPlayerEntit
|
|||||||
return self.coordinator.data.consoles[self._console.id]
|
return self.coordinator.data.consoles[self._console.id]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self) -> MediaPlayerState | None:
|
||||||
"""State of the player."""
|
"""State of the player."""
|
||||||
status = self.data.status
|
status = self.data.status
|
||||||
if status.playback_state in XBOX_STATE_MAP:
|
if status.playback_state in XBOX_STATE_MAP:
|
||||||
|
@ -145,7 +145,7 @@ class MusicCastMediaPlayer(MusicCastDeviceEntity, MediaPlayerEntity):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self) -> MediaPlayerState:
|
||||||
"""Return the state of the player."""
|
"""Return the state of the player."""
|
||||||
if self.coordinator.data.zones[self._zone_id].power == "on":
|
if self.coordinator.data.zones[self._zone_id].power == "on":
|
||||||
if self._is_netusb and self.coordinator.data.netusb_playback == "pause":
|
if self._is_netusb and self.coordinator.data.netusb_playback == "pause":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user