mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Implement 'volume_set' service for Android TV devices (#31161)
This commit is contained in:
parent
4c4f726323
commit
cd72128a80
@ -4,7 +4,7 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/androidtv",
|
"documentation": "https://www.home-assistant.io/integrations/androidtv",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"adb-shell==0.1.1",
|
"adb-shell==0.1.1",
|
||||||
"androidtv==0.0.38",
|
"androidtv==0.0.39",
|
||||||
"pure-python-adb==0.2.2.dev0"
|
"pure-python-adb==0.2.2.dev0"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
|
@ -26,6 +26,7 @@ from homeassistant.components.media_player.const import (
|
|||||||
SUPPORT_TURN_OFF,
|
SUPPORT_TURN_OFF,
|
||||||
SUPPORT_TURN_ON,
|
SUPPORT_TURN_ON,
|
||||||
SUPPORT_VOLUME_MUTE,
|
SUPPORT_VOLUME_MUTE,
|
||||||
|
SUPPORT_VOLUME_SET,
|
||||||
SUPPORT_VOLUME_STEP,
|
SUPPORT_VOLUME_STEP,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -59,6 +60,7 @@ SUPPORT_ANDROIDTV = (
|
|||||||
| SUPPORT_SELECT_SOURCE
|
| SUPPORT_SELECT_SOURCE
|
||||||
| SUPPORT_STOP
|
| SUPPORT_STOP
|
||||||
| SUPPORT_VOLUME_MUTE
|
| SUPPORT_VOLUME_MUTE
|
||||||
|
| SUPPORT_VOLUME_SET
|
||||||
| SUPPORT_VOLUME_STEP
|
| SUPPORT_VOLUME_STEP
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -631,6 +633,11 @@ class AndroidTVDevice(ADBDevice):
|
|||||||
"""Mute the volume."""
|
"""Mute the volume."""
|
||||||
self.aftv.mute_volume()
|
self.aftv.mute_volume()
|
||||||
|
|
||||||
|
@adb_decorator()
|
||||||
|
def set_volume_level(self, volume):
|
||||||
|
"""Set the volume level."""
|
||||||
|
self.aftv.set_volume_level(volume)
|
||||||
|
|
||||||
@adb_decorator()
|
@adb_decorator()
|
||||||
def volume_down(self):
|
def volume_down(self):
|
||||||
"""Send volume down command."""
|
"""Send volume down command."""
|
||||||
|
@ -220,7 +220,7 @@ ambiclimate==0.2.1
|
|||||||
amcrest==1.5.3
|
amcrest==1.5.3
|
||||||
|
|
||||||
# homeassistant.components.androidtv
|
# homeassistant.components.androidtv
|
||||||
androidtv==0.0.38
|
androidtv==0.0.39
|
||||||
|
|
||||||
# homeassistant.components.anel_pwrctrl
|
# homeassistant.components.anel_pwrctrl
|
||||||
anel_pwrctrl-homeassistant==0.0.1.dev2
|
anel_pwrctrl-homeassistant==0.0.1.dev2
|
||||||
|
@ -87,7 +87,7 @@ airly==0.0.2
|
|||||||
ambiclimate==0.2.1
|
ambiclimate==0.2.1
|
||||||
|
|
||||||
# homeassistant.components.androidtv
|
# homeassistant.components.androidtv
|
||||||
androidtv==0.0.38
|
androidtv==0.0.39
|
||||||
|
|
||||||
# homeassistant.components.apns
|
# homeassistant.components.apns
|
||||||
apns2==0.3.0
|
apns2==0.3.0
|
||||||
|
@ -28,6 +28,7 @@ from homeassistant.const import (
|
|||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_PLATFORM,
|
CONF_PLATFORM,
|
||||||
|
SERVICE_VOLUME_SET,
|
||||||
STATE_IDLE,
|
STATE_IDLE,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_PLAYING,
|
STATE_PLAYING,
|
||||||
@ -820,3 +821,25 @@ async def test_upload(hass):
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
patch_push.assert_called_with(local_path, device_path)
|
patch_push.assert_called_with(local_path, device_path)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_androidtv_volume_set(hass):
|
||||||
|
"""Test setting the volume for an Android TV device."""
|
||||||
|
patch_key, entity_id = _setup(CONFIG_ANDROIDTV_ADB_SERVER)
|
||||||
|
|
||||||
|
with patchers.PATCH_ADB_DEVICE_TCP, patchers.patch_connect(True)[
|
||||||
|
patch_key
|
||||||
|
], patchers.patch_shell("")[patch_key]:
|
||||||
|
assert await async_setup_component(hass, DOMAIN, CONFIG_ANDROIDTV_ADB_SERVER)
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"androidtv.basetv.BaseTV.set_volume_level", return_value=0.5
|
||||||
|
) as patch_set_volume_level:
|
||||||
|
await hass.services.async_call(
|
||||||
|
DOMAIN,
|
||||||
|
SERVICE_VOLUME_SET,
|
||||||
|
{ATTR_ENTITY_ID: entity_id, "volume_level": 0.5},
|
||||||
|
blocking=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
patch_set_volume_level.assert_called_with(0.5)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user