diff --git a/homeassistant/components/vizio/const.py b/homeassistant/components/vizio/const.py index 12de3af1cb0715..03caa723771576 100644 --- a/homeassistant/components/vizio/const.py +++ b/homeassistant/components/vizio/const.py @@ -52,7 +52,9 @@ DOMAIN = "vizio" COMMON_SUPPORTED_COMMANDS = ( - MediaPlayerEntityFeature.SELECT_SOURCE + MediaPlayerEntityFeature.PAUSE + | MediaPlayerEntityFeature.PLAY + | MediaPlayerEntityFeature.SELECT_SOURCE | MediaPlayerEntityFeature.TURN_ON | MediaPlayerEntityFeature.TURN_OFF | MediaPlayerEntityFeature.VOLUME_MUTE diff --git a/homeassistant/components/vizio/media_player.py b/homeassistant/components/vizio/media_player.py index c19c091bb3db5a..18af2c0dbb29a7 100644 --- a/homeassistant/components/vizio/media_player.py +++ b/homeassistant/components/vizio/media_player.py @@ -159,6 +159,7 @@ def __init__( ) self._device = device self._max_volume = float(device.get_max_volume()) + self._attr_assumed_state = True # Entity class attributes that will change with each update (we only include # the ones that are initialized differently from the defaults) @@ -483,3 +484,11 @@ async def async_set_volume_level(self, volume: float) -> None: num = int(self._max_volume * (self._attr_volume_level - volume)) await self._device.vol_down(num=num, log_api_exception=False) self._attr_volume_level = volume + + async def async_media_play(self) -> None: + """Play whatever media is currently active.""" + await self._device.play(log_api_exception=False) + + async def async_media_pause(self) -> None: + """Pause whatever media is currently active.""" + await self._device.pause(log_api_exception=False) diff --git a/tests/components/vizio/test_media_player.py b/tests/components/vizio/test_media_player.py index d5ce18eb8b9544..8cc734b9188770 100644 --- a/tests/components/vizio/test_media_player.py +++ b/tests/components/vizio/test_media_player.py @@ -28,6 +28,8 @@ ATTR_SOUND_MODE, DOMAIN as MP_DOMAIN, SERVICE_MEDIA_NEXT_TRACK, + SERVICE_MEDIA_PAUSE, + SERVICE_MEDIA_PLAY, SERVICE_MEDIA_PREVIOUS_TRACK, SERVICE_SELECT_SOUND_MODE, SERVICE_SELECT_SOURCE, @@ -443,6 +445,8 @@ async def test_services( "eq", "Music", ) + await _test_service(hass, MP_DOMAIN, "play", SERVICE_MEDIA_PLAY, None) + await _test_service(hass, MP_DOMAIN, "pause", SERVICE_MEDIA_PAUSE, None) async def test_options_update(