mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Assumed state in Bravia TV media player (#84885)
This commit is contained in:
parent
e5b6f05e5b
commit
ed0e583556
@ -95,8 +95,6 @@ class BraviaTVCoordinator(DataUpdateCoordinator[None]):
|
||||
self.is_on = False
|
||||
self.is_channel = False
|
||||
self.connected = False
|
||||
# Assume that the TV is in Play mode
|
||||
self.playing = True
|
||||
self.skipped_updates = 0
|
||||
|
||||
super().__init__(
|
||||
@ -249,13 +247,11 @@ class BraviaTVCoordinator(DataUpdateCoordinator[None]):
|
||||
async def async_media_play(self) -> None:
|
||||
"""Send play command to device."""
|
||||
await self.client.play()
|
||||
self.playing = True
|
||||
|
||||
@catch_braviatv_errors
|
||||
async def async_media_pause(self) -> None:
|
||||
"""Send pause command to device."""
|
||||
await self.client.pause()
|
||||
self.playing = False
|
||||
|
||||
@catch_braviatv_errors
|
||||
async def async_media_stop(self) -> None:
|
||||
|
@ -35,6 +35,7 @@ async def async_setup_entry(
|
||||
class BraviaTVMediaPlayer(BraviaTVEntity, MediaPlayerEntity):
|
||||
"""Representation of a Bravia TV Media Player."""
|
||||
|
||||
_attr_assumed_state = True
|
||||
_attr_device_class = MediaPlayerDeviceClass.TV
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
@ -54,11 +55,7 @@ class BraviaTVMediaPlayer(BraviaTVEntity, MediaPlayerEntity):
|
||||
def state(self) -> MediaPlayerState:
|
||||
"""Return the state of the device."""
|
||||
if self.coordinator.is_on:
|
||||
return (
|
||||
MediaPlayerState.PLAYING
|
||||
if self.coordinator.playing
|
||||
else MediaPlayerState.PAUSED
|
||||
)
|
||||
return MediaPlayerState.ON
|
||||
return MediaPlayerState.OFF
|
||||
|
||||
@property
|
||||
@ -137,6 +134,10 @@ class BraviaTVMediaPlayer(BraviaTVEntity, MediaPlayerEntity):
|
||||
"""Send pause command."""
|
||||
await self.coordinator.async_media_pause()
|
||||
|
||||
async def async_media_play_pause(self) -> None:
|
||||
"""Send pause command that toggle play/pause."""
|
||||
await self.coordinator.async_media_pause()
|
||||
|
||||
async def async_media_stop(self) -> None:
|
||||
"""Send media stop command to media player."""
|
||||
await self.coordinator.async_media_stop()
|
||||
|
Loading…
x
Reference in New Issue
Block a user