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))