mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Don't attempt to set Vizio is_volume_muted property if Vizio API doesn't provide muted state (#34782)
This commit is contained in:
parent
793592b2b8
commit
3e06e6b4b3
@ -132,7 +132,7 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
self._state = None
|
self._state = None
|
||||||
self._volume_level = None
|
self._volume_level = None
|
||||||
self._volume_step = config_entry.options[CONF_VOLUME_STEP]
|
self._volume_step = config_entry.options[CONF_VOLUME_STEP]
|
||||||
self._is_muted = None
|
self._is_volume_muted = None
|
||||||
self._current_input = None
|
self._current_input = None
|
||||||
self._current_app = None
|
self._current_app = None
|
||||||
self._current_app_config = None
|
self._current_app_config = None
|
||||||
@ -190,7 +190,7 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
if not is_on:
|
if not is_on:
|
||||||
self._state = STATE_OFF
|
self._state = STATE_OFF
|
||||||
self._volume_level = None
|
self._volume_level = None
|
||||||
self._is_muted = None
|
self._is_volume_muted = None
|
||||||
self._current_input = None
|
self._current_input = None
|
||||||
self._available_inputs = None
|
self._available_inputs = None
|
||||||
self._current_app = None
|
self._current_app = None
|
||||||
@ -207,7 +207,10 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
)
|
)
|
||||||
if audio_settings is not None:
|
if audio_settings is not None:
|
||||||
self._volume_level = float(audio_settings["volume"]) / self._max_volume
|
self._volume_level = float(audio_settings["volume"]) / self._max_volume
|
||||||
self._is_muted = audio_settings["mute"].lower() == "on"
|
if "mute" in audio_settings:
|
||||||
|
self._is_volume_muted = audio_settings["mute"].lower() == "on"
|
||||||
|
else:
|
||||||
|
self._is_volume_muted = None
|
||||||
|
|
||||||
if VIZIO_SOUND_MODE in audio_settings:
|
if VIZIO_SOUND_MODE in audio_settings:
|
||||||
self._supported_commands |= SUPPORT_SELECT_SOUND_MODE
|
self._supported_commands |= SUPPORT_SELECT_SOUND_MODE
|
||||||
@ -324,7 +327,7 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
@property
|
@property
|
||||||
def is_volume_muted(self):
|
def is_volume_muted(self):
|
||||||
"""Boolean if volume is currently muted."""
|
"""Boolean if volume is currently muted."""
|
||||||
return self._is_muted
|
return self._is_volume_muted
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source(self) -> str:
|
def source(self) -> str:
|
||||||
@ -428,10 +431,10 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
"""Mute the volume."""
|
"""Mute the volume."""
|
||||||
if mute:
|
if mute:
|
||||||
await self._device.mute_on()
|
await self._device.mute_on()
|
||||||
self._is_muted = True
|
self._is_volume_muted = True
|
||||||
else:
|
else:
|
||||||
await self._device.mute_off()
|
await self._device.mute_off()
|
||||||
self._is_muted = False
|
self._is_volume_muted = False
|
||||||
|
|
||||||
async def async_media_previous_track(self) -> None:
|
async def async_media_previous_track(self) -> None:
|
||||||
"""Send previous channel command."""
|
"""Send previous channel command."""
|
||||||
|
@ -621,3 +621,26 @@ async def test_setup_with_no_running_app(
|
|||||||
assert attr["source"] == "CAST"
|
assert attr["source"] == "CAST"
|
||||||
assert "app_id" not in attr
|
assert "app_id" not in attr
|
||||||
assert "app_name" not in attr
|
assert "app_name" not in attr
|
||||||
|
|
||||||
|
|
||||||
|
async def test_setup_tv_without_mute(
|
||||||
|
hass: HomeAssistantType,
|
||||||
|
vizio_connect: pytest.fixture,
|
||||||
|
vizio_update: pytest.fixture,
|
||||||
|
) -> None:
|
||||||
|
"""Test Vizio TV entity setup when mute property isn't returned by Vizio API."""
|
||||||
|
config_entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
data=vol.Schema(VIZIO_SCHEMA)(MOCK_USER_VALID_TV_CONFIG),
|
||||||
|
unique_id=UNIQUE_ID,
|
||||||
|
)
|
||||||
|
|
||||||
|
async with _cm_for_test_setup_without_apps(
|
||||||
|
{"volume": int(MAX_VOLUME[VIZIO_DEVICE_CLASS_TV] / 2)}, STATE_ON,
|
||||||
|
):
|
||||||
|
await _add_config_entry_to_hass(hass, config_entry)
|
||||||
|
|
||||||
|
attr = _get_attr_and_assert_base_attr(hass, DEVICE_CLASS_TV, STATE_ON)
|
||||||
|
_assert_sources_and_volume(attr, VIZIO_DEVICE_CLASS_TV)
|
||||||
|
assert "sound_mode" not in attr
|
||||||
|
assert "is_volume_muted" not in attr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user