From f18c0bf6268119bbd580175a6b377658c739121c Mon Sep 17 00:00:00 2001 From: Artem Draft Date: Sat, 25 Feb 2023 09:43:58 +0300 Subject: [PATCH] Pass `assumed_state` property in universal media player (#87846) Pass assumed_state property in universal media player --- homeassistant/components/universal/media_player.py | 6 ++++++ tests/components/universal/test_media_player.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/homeassistant/components/universal/media_player.py b/homeassistant/components/universal/media_player.py index 2cbe7aa6fb1..9f6c9db416e 100644 --- a/homeassistant/components/universal/media_player.py +++ b/homeassistant/components/universal/media_player.py @@ -47,6 +47,7 @@ from homeassistant.components.media_player import ( ) from homeassistant.components.media_player.browse_media import BrowseMedia from homeassistant.const import ( + ATTR_ASSUMED_STATE, ATTR_ENTITY_ID, ATTR_ENTITY_PICTURE, ATTR_SUPPORTED_FEATURES, @@ -291,6 +292,11 @@ class UniversalMediaPlayer(MediaPlayerEntity): """Return the name of universal player.""" return self._name + @property + def assumed_state(self) -> bool: + """Return True if unable to access real state of the entity.""" + return self._child_attr(ATTR_ASSUMED_STATE) + @property def state(self): """Return the current state of media player. diff --git a/tests/components/universal/test_media_player.py b/tests/components/universal/test_media_player.py index 81204fe21c2..fd8c572685c 100644 --- a/tests/components/universal/test_media_player.py +++ b/tests/components/universal/test_media_player.py @@ -492,6 +492,13 @@ async def test_state_children_only(hass: HomeAssistant, mock_states) -> None: await ump.async_update() assert ump.state == STATE_PLAYING + mock_states.mock_mp_1._state = STATE_ON + mock_states.mock_mp_1._attr_assumed_state = True + mock_states.mock_mp_1.async_schedule_update_ha_state() + await hass.async_block_till_done() + await ump.async_update() + assert ump.assumed_state is True + async def test_state_with_children_and_attrs( hass: HomeAssistant, config_children_and_attr, mock_states