diff --git a/homeassistant/components/universal/media_player.py b/homeassistant/components/universal/media_player.py index 5deebc4103b8fa..8356e289094d18 100644 --- a/homeassistant/components/universal/media_player.py +++ b/homeassistant/components/universal/media_player.py @@ -162,7 +162,7 @@ def __init__( ): """Initialize the Universal media device.""" self.hass = hass - self._name = config.get(CONF_NAME) + self._attr_name = config.get(CONF_NAME) self._children = config.get(CONF_CHILDREN) self._active_child_template = config.get(CONF_ACTIVE_CHILD_TEMPLATE) self._active_child_template_result = None @@ -189,7 +189,8 @@ def _async_on_dependency_update( ) -> None: """Update ha state when dependencies update.""" self.async_set_context(event.context) - self.async_schedule_update_ha_state(True) + self._async_update() + self.async_write_ha_state() @callback def _async_on_template_update( @@ -213,7 +214,8 @@ def _async_on_template_update( if event: self.async_set_context(event.context) - self.async_schedule_update_ha_state(True) + self._async_update() + self.async_write_ha_state() track_templates: list[TrackTemplate] = [] if self._state_template: @@ -306,11 +308,6 @@ def master_state(self): return None - @property - def name(self): - """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.""" @@ -659,7 +656,8 @@ async def async_browse_media( return await entity.async_browse_media(media_content_type, media_content_id) raise NotImplementedError - async def async_update(self) -> None: + @callback + def _async_update(self) -> None: """Update state in HA.""" if self._active_child_template_result: self._child_state = self.hass.states.get(self._active_child_template_result) @@ -676,3 +674,7 @@ async def async_update(self) -> None: self._child_state = child_state else: self._child_state = child_state + + async def async_update(self) -> None: + """Manual update from API.""" + self._async_update()