mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 07:51:46 -05:00
Fix Vizio soundbars requiring authentication (#181556)
This commit is contained in:
@@ -151,10 +151,10 @@ class VizioDeviceCoordinator(DataUpdateCoordinator[VizioDeviceData]):
|
||||
update_interval=SCAN_INTERVAL,
|
||||
)
|
||||
self.device = device
|
||||
# Modern firmware bundles power/input/app state into one endpoint;
|
||||
# Modern TV firmware bundles power/input/app state into one endpoint;
|
||||
# firmware without it never gains it, so probe only until the first
|
||||
# URI_NOT_FOUND response.
|
||||
self._use_state_extended = True
|
||||
# URI_NOT_FOUND response. Audio devices do not support this endpoint.
|
||||
self._use_state_extended = device.profile.has_inputs
|
||||
|
||||
@override
|
||||
async def _async_setup(self) -> None:
|
||||
|
||||
@@ -13,6 +13,7 @@ from vizaio import (
|
||||
VizioConnectionError,
|
||||
VizioNotFoundError,
|
||||
)
|
||||
from vizaio.profiles import SOUNDBAR_PROFILE
|
||||
|
||||
from homeassistant.components.media_player import (
|
||||
DOMAIN as MEDIA_PLAYER_DOMAIN,
|
||||
@@ -226,6 +227,23 @@ async def test_state_extended_polling(
|
||||
mock_vizio.get_current_app_config.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("vizio_connect")
|
||||
async def test_soundbar_does_not_poll_state_extended(
|
||||
hass: HomeAssistant,
|
||||
mock_speaker_config_entry: MockConfigEntry,
|
||||
mock_vizio: AsyncMock,
|
||||
) -> None:
|
||||
"""Test soundbars use the unauthenticated power endpoint."""
|
||||
mock_vizio.profile = SOUNDBAR_PROFILE
|
||||
mock_vizio.get_state_extended.side_effect = VizioAuthError("token required")
|
||||
|
||||
await setup_integration(hass, mock_speaker_config_entry)
|
||||
|
||||
mock_vizio.get_state_extended.assert_not_called()
|
||||
mock_vizio.get_power_state.assert_called_once()
|
||||
assert not hass.config_entries.flow.async_progress_by_handler(DOMAIN)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("vizio_connect")
|
||||
async def test_state_extended_power_off(
|
||||
hass: HomeAssistant,
|
||||
|
||||
Reference in New Issue
Block a user