clean up code to improve consistency and revert previous change (#35752)
This commit is contained in:
parent
2a86d52dba
commit
cd054a9579
2 changed files with 12 additions and 10 deletions
|
@ -65,6 +65,7 @@ SUPPORTED_COMMANDS = {
|
|||
|
||||
VIZIO_SOUND_MODE = "eq"
|
||||
VIZIO_AUDIO_SETTINGS = "audio"
|
||||
VIZIO_MUTE_ON = "on"
|
||||
|
||||
# Since Vizio component relies on device class, this dict will ensure that changes to
|
||||
# the values of DEVICE_CLASS_SPEAKER or DEVICE_CLASS_TV don't require changes to pyvizio.
|
||||
|
|
|
@ -44,6 +44,7 @@ from .const import (
|
|||
SUPPORTED_COMMANDS,
|
||||
VIZIO_AUDIO_SETTINGS,
|
||||
VIZIO_DEVICE_CLASSES,
|
||||
VIZIO_MUTE_ON,
|
||||
VIZIO_SOUND_MODE,
|
||||
)
|
||||
|
||||
|
@ -202,10 +203,10 @@ class VizioDevice(MediaPlayerEntity):
|
|||
audio_settings = await self._device.get_all_settings(
|
||||
VIZIO_AUDIO_SETTINGS, log_api_exception=False
|
||||
)
|
||||
if audio_settings is not None:
|
||||
if audio_settings:
|
||||
self._volume_level = float(audio_settings["volume"]) / self._max_volume
|
||||
if "mute" in audio_settings:
|
||||
self._is_volume_muted = audio_settings["mute"].lower() == "on"
|
||||
self._is_volume_muted = audio_settings["mute"].lower() == VIZIO_MUTE_ON
|
||||
else:
|
||||
self._is_volume_muted = None
|
||||
|
||||
|
@ -217,20 +218,20 @@ class VizioDevice(MediaPlayerEntity):
|
|||
VIZIO_AUDIO_SETTINGS, VIZIO_SOUND_MODE
|
||||
)
|
||||
else:
|
||||
self._supported_commands ^= SUPPORT_SELECT_SOUND_MODE
|
||||
# Explicitly remove SUPPORT_SELECT_SOUND_MODE from supported features
|
||||
self._supported_commands &= ~SUPPORT_SELECT_SOUND_MODE
|
||||
|
||||
input_ = await self._device.get_current_input(log_api_exception=False)
|
||||
if input_ is not None:
|
||||
if input_:
|
||||
self._current_input = input_
|
||||
|
||||
if not self._available_inputs:
|
||||
inputs = await self._device.get_inputs_list(log_api_exception=False)
|
||||
inputs = await self._device.get_inputs_list(log_api_exception=False)
|
||||
|
||||
# If no inputs returned, end update
|
||||
if not inputs:
|
||||
return
|
||||
# If no inputs returned, end update
|
||||
if not inputs:
|
||||
return
|
||||
|
||||
self._available_inputs = [input_.name for input_ in inputs]
|
||||
self._available_inputs = [input_.name for input_ in inputs]
|
||||
|
||||
# Return before setting app variables if INPUT_APPS isn't in available inputs
|
||||
if self._device_class == DEVICE_CLASS_SPEAKER or not any(
|
||||
|
|
Loading…
Add table
Reference in a new issue