From fe6ca522e8fed2b93282d1dbeb97fe32e40ec2dd Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Thu, 12 Mar 2020 06:01:05 -0400 Subject: [PATCH] =?UTF-8?q?Update=20Vizio=20`source`=20property=20to=20onl?= =?UTF-8?q?y=20return=20current=20app=20if=20i=E2=80=A6=20(#32713)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * only return current app for source if current app is set * check for None specifically * make sure current app isn't called for speaker --- homeassistant/components/vizio/media_player.py | 2 +- tests/components/vizio/test_media_player.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/vizio/media_player.py b/homeassistant/components/vizio/media_player.py index 63918737411..69a430bb997 100644 --- a/homeassistant/components/vizio/media_player.py +++ b/homeassistant/components/vizio/media_player.py @@ -304,7 +304,7 @@ class VizioDevice(MediaPlayerDevice): @property def source(self) -> str: """Return current input of the device.""" - if self._current_input in INPUT_APPS: + if self._current_app is not None and self._current_input in INPUT_APPS: return self._current_app return self._current_input diff --git a/tests/components/vizio/test_media_player.py b/tests/components/vizio/test_media_player.py index 19696af73a2..68366e8e98b 100644 --- a/tests/components/vizio/test_media_player.py +++ b/tests/components/vizio/test_media_player.py @@ -112,7 +112,9 @@ async def _test_setup( ), patch( "homeassistant.components.vizio.media_player.VizioAsync.get_power_state", return_value=vizio_power_state, - ): + ), patch( + "homeassistant.components.vizio.media_player.VizioAsync.get_current_app", + ) as service_call: config_entry.add_to_hass(hass) assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() @@ -125,6 +127,8 @@ async def _test_setup( if ha_power_state == STATE_ON: assert attr["source_list"] == INPUT_LIST assert attr["source"] == CURRENT_INPUT + if ha_device_class == DEVICE_CLASS_SPEAKER: + assert not service_call.called assert ( attr["volume_level"] == float(int(MAX_VOLUME[vizio_device_class] / 2))