diff --git a/homeassistant/components/androidtv/manifest.json b/homeassistant/components/androidtv/manifest.json index 902688742ba..8edf6460f65 100644 --- a/homeassistant/components/androidtv/manifest.json +++ b/homeassistant/components/androidtv/manifest.json @@ -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"] diff --git a/homeassistant/components/androidtv/media_player.py b/homeassistant/components/androidtv/media_player.py index b13a2000e5b..5133b5cd5bb 100644 --- a/homeassistant/components/androidtv/media_player.py +++ b/homeassistant/components/androidtv/media_player.py @@ -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: diff --git a/requirements_all.txt b/requirements_all.txt index f1f46a8754e..081e70a9901 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index a66cd50ba11..2e57dced64c 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -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 diff --git a/tests/components/androidtv/patchers.py b/tests/components/androidtv/patchers.py index a89abe33de3..b5b6bbd0a46 100644 --- a/tests/components/androidtv/patchers.py +++ b/tests/components/androidtv/patchers.py @@ -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, ), ) diff --git a/tests/components/androidtv/test_media_player.py b/tests/components/androidtv/test_media_player.py index c497a9daa48..0594a420852 100644 --- a/tests/components/androidtv/test_media_player.py +++ b/tests/components/androidtv/test_media_player.py @@ -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: