From 4bc236ec33984c59af940a24f9a1e4c391fffb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o?= <111107131+LEOBOESE@users.noreply.github.com> Date: Sat, 8 Nov 2025 23:55:36 -0300 Subject: [PATCH] Replace MEDIA_TYPE_MUSIC with MediaType.MUSIC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The constant MEDIA_TYPE_MUSIC (and possibly others in the same group) has been removed in recent Home Assistant versions. The HASS.Agent integration’s media_player.py file was still trying to import it from homeassistant.components.media_player.const, which caused an import error (ImportError: cannot import name 'MEDIA_TYPE_MUSIC'). What was done: Updated the imports and references to use the new enums introduced by Home Assistant. The code now imports from homeassistant.components.media_player import MediaType and uses MediaType.MUSIC instead of the deprecated MEDIA_TYPE_MUSIC constant. Result: The integration now loads the media_player platform correctly again, restoring compatibility with the latest versions of Home Assistant. --- custom_components/hass_agent/media_player.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/hass_agent/media_player.py b/custom_components/hass_agent/media_player.py index b4f4bb9..598dd33 100644 --- a/custom_components/hass_agent/media_player.py +++ b/custom_components/hass_agent/media_player.py @@ -25,7 +25,7 @@ MediaPlayerEntityFeature, ) -from homeassistant.components.media_player.const import MEDIA_TYPE_MUSIC +from homeassistant.components.media_player import MediaType from homeassistant.components.media_player.browse_media import ( BrowseMedia, @@ -232,7 +232,7 @@ def device_class(self): @property def media_content_type(self): """Content type of current playing media""" - return MEDIA_TYPE_MUSIC + return MediaType.MUSIC async def async_media_seek(self, position: float) -> None: self._attr_media_position = position @@ -293,7 +293,7 @@ async def async_play_media(self, media_type: str, media_id: str, **kwargs: Any): _logger.error( "Invalid media type %r. Only %s is supported!", media_type, - MEDIA_TYPE_MUSIC, + MediaType.MUSIC, ) return