Add hdmi input attribute to AndroidTV (#42571)

* bumps androidtv to 0.0.53

* add hdmi_input attribute to androidtv

* update tests for hdmi_input attribute

* chore: update docstrings
This commit is contained in:
Diederik van den Burger 2020-11-05 14:36:46 +01:00 committed by GitHub
parent f16ccae78b
commit 60234ecf40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 12 deletions

View File

@ -4,7 +4,7 @@
"documentation": "https://www.home-assistant.io/integrations/androidtv",
"requirements": [
"adb-shell[async]==0.2.1",
"androidtv[async]==0.0.52",
"androidtv[async]==0.0.53",
"pure-python-adb[async]==0.3.0.dev0"
],
"codeowners": ["@JeffLIrion"]

View File

@ -445,6 +445,7 @@ class ADBDevice(MediaPlayerEntity):
self._current_app = None
self._sources = None
self._state = None
self._hdmi_input = None
@property
def app_id(self):
@ -463,8 +464,11 @@ class ADBDevice(MediaPlayerEntity):
@property
def device_state_attributes(self):
"""Provide the last ADB command's response as an attribute."""
return {"adb_response": self._adb_response}
"""Provide the last ADB command's response and the device's HDMI input as attributes."""
return {
"adb_response": self._adb_response,
"hdmi_input": self._hdmi_input,
}
@property
def media_image_hash(self):
@ -670,6 +674,7 @@ class AndroidTVDevice(ADBDevice):
_,
self._is_volume_muted,
self._volume_level,
self._hdmi_input,
) = await self.aftv.update(self._get_sources)
self._state = ANDROIDTV_STATES.get(state)
@ -743,10 +748,13 @@ class FireTVDevice(ADBDevice):
if not self._available:
return
# Get the `state`, `current_app`, and `running_apps`.
state, self._current_app, running_apps = await self.aftv.update(
self._get_sources
)
# Get the `state`, `current_app`, `running_apps` and `hdmi_input`.
(
state,
self._current_app,
running_apps,
self._hdmi_input,
) = await self.aftv.update(self._get_sources)
self._state = ANDROIDTV_STATES.get(state)
if self._state is None:

View File

@ -248,7 +248,7 @@ ambiclimate==0.2.1
amcrest==1.7.0
# homeassistant.components.androidtv
androidtv[async]==0.0.52
androidtv[async]==0.0.53
# homeassistant.components.anel_pwrctrl
anel_pwrctrl-homeassistant==0.0.1.dev2

View File

@ -155,7 +155,7 @@ airly==1.0.0
ambiclimate==0.2.1
# homeassistant.components.androidtv
androidtv[async]==0.0.52
androidtv[async]==0.0.53
# homeassistant.components.apns
apns2==0.3.0

View File

@ -155,16 +155,16 @@ PATCH_ISFILE = patch("os.path.isfile", isfile)
PATCH_ACCESS = patch("os.access", return_value=True)
def patch_firetv_update(state, current_app, running_apps):
def patch_firetv_update(state, current_app, running_apps, hdmi_input):
"""Patch the `FireTV.update()` method."""
return patch(
"androidtv.firetv.firetv_async.FireTVAsync.update",
return_value=(state, current_app, running_apps),
return_value=(state, current_app, running_apps, hdmi_input),
)
def patch_androidtv_update(
state, current_app, running_apps, device, is_volume_muted, volume_level
state, current_app, running_apps, device, is_volume_muted, volume_level, hdmi_input
):
"""Patch the `AndroidTV.update()` method."""
return patch(
@ -176,6 +176,7 @@ def patch_androidtv_update(
device,
is_volume_muted,
volume_level,
hdmi_input,
),
)

View File

@ -341,12 +341,14 @@ async def _test_sources(hass, config0):
"hdmi",
False,
1,
"HW5",
)
else:
patch_update = patchers.patch_firetv_update(
"playing",
"com.app.test1",
["com.app.test1", "com.app.test2", "com.app.test3", "com.app.test4"],
"HW5",
)
with patch_update:
@ -365,12 +367,14 @@ async def _test_sources(hass, config0):
"hdmi",
True,
0,
"HW5",
)
else:
patch_update = patchers.patch_firetv_update(
"playing",
"com.app.test2",
["com.app.test2", "com.app.test1", "com.app.test3", "com.app.test4"],
"HW5",
)
with patch_update:
@ -428,6 +432,7 @@ async def _test_exclude_sources(hass, config0, expected_sources):
"hdmi",
False,
1,
"HW5",
)
else:
patch_update = patchers.patch_firetv_update(
@ -440,6 +445,7 @@ async def _test_exclude_sources(hass, config0, expected_sources):
"com.app.test4",
"com.app.test5",
],
"HW5",
)
with patch_update: