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