Skip to content

Commit

Permalink
Merge pull request #1 from JackJPowell:Fix-Media-Player-State
Browse files Browse the repository at this point in the history
Report correct media player state when playing
  • Loading branch information
JackJPowell authored May 26, 2024
2 parents 521b21e + 03fd9f1 commit beadaeb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions custom_components/playstation_network/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ async def async_setup_entry(
class MediaPlayer(PSNEntity, MediaPlayerEntity):
"""Media player entity representing currently playing game"""

device_class = MediaPlayerDeviceClass.RECEIVER
_attr_supported_features = (
MediaPlayerEntityFeature.TURN_OFF | MediaPlayerEntityFeature.TURN_ON
)
device_class = MediaPlayerDeviceClass.TV
_attr_supported_features = None

def __init__(self, coordinator) -> None:
"""Initialize PSN MediaPlayer."""
Expand All @@ -66,7 +64,13 @@ def media_image_remotely_accessible(self):
def state(self):
match self.data.get("platform").get("onlineStatus"):
case "online":
return MediaPlayerState.ON
if (
self.data.get("available") is True
and self.data.get("title_metadata").get("npTitleId") is not None
):
return MediaPlayerState.PLAYING
else:
return MediaPlayerState.ON
case "offline":
return MediaPlayerState.OFF
case _:
Expand All @@ -90,7 +94,7 @@ def media_title(self):
if self.data.get("title_metadata").get("npTitleId"):
return self.data.get("title_metadata").get("titleName")
if self.data.get("platform").get("onlineStatus") == "online":
return "Playstation Online"
return "Browsing the Menu"
else:
return None

Expand Down

0 comments on commit beadaeb

Please sign in to comment.