mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Add play/pause functionality for Vizio Smartcast media_player entities (#108896)
* Add play/pause functionality to vizio integration Leverages existing pyvizio functionality. My impression is that it also works for soundbars based on https://github.com/exiva/Vizio_SmartCast_API/issues/19. * Set vizio assumed_state to True The Vizio API is only capable of indicating whether the device is on or off and not whether it's playing/paused/idle. Setting assumed_state to True gives us separate Play and Pause buttons versus the (useless) merged Play/Pause button we would get otherwise.
This commit is contained in:
parent
f2fe62d159
commit
12c2ed5c4d
@ -52,7 +52,9 @@ DEVICE_ID = "pyvizio"
|
||||
DOMAIN = "vizio"
|
||||
|
||||
COMMON_SUPPORTED_COMMANDS = (
|
||||
MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
|
@ -159,6 +159,7 @@ class VizioDevice(MediaPlayerEntity):
|
||||
)
|
||||
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 @@ class VizioDevice(MediaPlayerEntity):
|
||||
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)
|
||||
|
@ -28,6 +28,8 @@ from homeassistant.components.media_player import (
|
||||
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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user