Drop the unknown-app sentinel from vizio app_name on non-app inputs (#181417)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Raman Gupta
2026-09-11 18:21:29 +00:00
committed by Franck Nijhof
co-authored by Claude Fable 5.1
parent 717e4a9bcb
commit 4509f0e0f1
2 changed files with 43 additions and 7 deletions
@@ -208,12 +208,17 @@ class VizioDevice(VizioEntity, MediaPlayerEntity):
else ()
),
)
# find_app_name returns None on a catalog miss; the app_name state
# attribute contract expects the UNKNOWN_APP sentinel instead
# A catalog miss only warrants the UNKNOWN_APP sentinel on the app
# input; HDMI and the like report a config that is never an app.
if app_name == NO_APP_RUNNING:
self._attr_app_name = None
elif app_name is None:
self._attr_app_name = UNKNOWN_APP
self._attr_app_name = (
UNKNOWN_APP
if self._current_input is not None
and is_app_input(self._current_input)
else None
)
else:
self._attr_app_name = app_name
+35 -4
View File
@@ -855,14 +855,45 @@ async def test_apps_update(
assert len(apps) == len(APP_RECORDS)
@pytest.mark.parametrize(
("entry_data", "app_config", "expected_app_name"),
[
pytest.param(
MOCK_USER_VALID_TV_CONFIG,
UNKNOWN_APP_CONFIG_OBJ,
None,
id="unknown_config_hides_app_name",
),
pytest.param(
MOCK_TV_WITH_ADDITIONAL_APPS_CONFIG,
CUSTOM_CONFIG_OBJ,
ADDITIONAL_APP_CONFIG["name"],
id="additional_config_keeps_mapped_name",
),
],
)
@pytest.mark.usefixtures("vizio_connect", "vizio_update_with_apps_on_input")
async def test_vizio_update_with_apps_on_input(
hass: HomeAssistant, mock_tv_config_entry: MockConfigEntry
hass: HomeAssistant,
entry_data: dict[str, Any],
app_config: AppConfig,
expected_app_name: str | None,
) -> None:
"""Test a vizio TV with apps that is on a TV input."""
await setup_integration(hass, mock_tv_config_entry)
"""Test a vizio TV with apps that is on a TV input.
The device reports an app config even on HDMI. An unrecognized one must
not surface as the unknown-app sentinel, while a name mapped through
additional_configs is deliberate user configuration and is kept.
"""
config_entry = MockConfigEntry(domain=DOMAIN, data=entry_data, unique_id=UNIQUE_ID)
with patch(
"homeassistant.components.vizio.Vizio.get_current_app_config",
return_value=app_config,
):
await setup_integration(hass, config_entry)
attr = _get_attr_and_assert_base_attr(hass, MediaPlayerDeviceClass.TV, STATE_ON)
# app ID should not be in the attributes
assert attr[ATTR_INPUT_SOURCE] == CURRENT_INPUT
assert attr.get("app_name") == expected_app_name
assert "app_id" not in attr