mirror of
https://github.com/home-assistant/core.git
synced 2026-09-24 23:41:48 -05:00
Add app_id attribute to webostv media player (#181385)
This commit is contained in:
@@ -148,6 +148,7 @@ class LgWebOSMediaPlayerEntity(WebOsTvEntity, RestoreEntity, MediaPlayerEntity):
|
||||
|
||||
self._attr_source = self._current_source
|
||||
self._attr_source_list = sorted(self._source_list)
|
||||
self._attr_app_id = tv_state.current_app_id
|
||||
|
||||
self._attr_media_content_type = None
|
||||
if tv_state.current_app_id == LIVE_TV_APP_ID:
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# name: test_entity_attributes
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
<MediaPlayerEntityStateAttribute.APP_ID: 'app_id'>: 'com.webos.app.livetv',
|
||||
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'tv',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'LG webOS TV MODEL',
|
||||
<MediaPlayerEntityStateAttribute.MEDIA_VOLUME_MUTED: 'is_volume_muted'>: False,
|
||||
|
||||
@@ -11,6 +11,7 @@ from syrupy.filters import props
|
||||
|
||||
from homeassistant.components import automation
|
||||
from homeassistant.components.media_player import (
|
||||
ATTR_APP_ID,
|
||||
ATTR_INPUT_SOURCE,
|
||||
ATTR_INPUT_SOURCE_LIST,
|
||||
ATTR_MEDIA_CONTENT_ID,
|
||||
@@ -537,6 +538,20 @@ async def test_update_sources_live_tv_find(hass: HomeAssistant, client) -> None:
|
||||
assert len(sources) == 1
|
||||
|
||||
|
||||
async def test_app_id(hass: HomeAssistant, client) -> None:
|
||||
"""Test app_id follows the foreground app id reported by the TV."""
|
||||
await setup_webostv(hass)
|
||||
await client.mock_state_update()
|
||||
|
||||
assert hass.states.get(ENTITY_ID).attributes[ATTR_APP_ID] == LIVE_TV_APP_ID
|
||||
|
||||
# apps outside the source list still get a usable app id
|
||||
client.tv_state.current_app_id = "com.webos.app.home"
|
||||
await client.mock_state_update()
|
||||
|
||||
assert hass.states.get(ENTITY_ID).attributes[ATTR_APP_ID] == "com.webos.app.home"
|
||||
|
||||
|
||||
async def test_client_disconnected(
|
||||
hass: HomeAssistant,
|
||||
client,
|
||||
|
||||
Reference in New Issue
Block a user