home-assistant/core · error · HomeAssistantError
invalid_media_type
invalid_media_type
Error message
Invalid media type: {media_type} What it means
Raised as HomeAssistantError (translation invalid_media_type) when play_media receives a media_type that is neither CHANNEL, URL, nor APP. The integration supports exactly those three types; anything else is rejected before any device I/O. It is the terminal else-branch of async_play_media.
Source
Thrown at homeassistant/components/androidtv_remote/media_player.py:208
if not media_id.isnumeric():
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="invalid_channel",
translation_placeholders={"media_id": media_id},
)
if self._channel_set_task:
self._channel_set_task.cancel()
self._channel_set_task = asyncio.create_task(
self._send_key_commands(list(media_id))
)
await self._channel_set_task
return
if media_type in [MediaType.URL, MediaType.APP]:
self._send_launch_app_command(media_id)
return
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="invalid_media_type",
translation_placeholders={"media_type": media_type},
)
@override
async def async_browse_media(
self,
media_content_type: MediaType | str | None = None,
media_content_id: str | None = None,
) -> BrowseMedia:
"""Browse apps."""
children = [
BrowseMedia(
media_class=MediaClass.APP,
media_content_type=MediaType.APP,
media_content_id=app_id,
title=app.get(CONF_APP_NAME, ""),View on GitHub (pinned to 58a3fdb3ea)
Solutions
- Use media_content_type: channel (numeric), app, or url only.
- For content in apps, launch the app with media_type app and the app link.
- Adjust the automation/frontend card to not target this entity with unsupported types.
Example fix
// before action: media_player.play_media target: entity_id: media_player.living_room_tv data: media_content_type: music media_content_id: "song.mp3" // after action: media_player.play_media target: entity_id: media_player.living_room_tv data: media_content_type: app media_content_id: "https://www.youtube.com"
Defensive patterns
Strategy: validation
Validate before calling
supported = {'channel', 'url', 'app'}
assert media_type in supported, f'unsupported media type {media_type}' Type guard
def is_supported_media_type(media_type: str) -> bool:
return media_type in {'channel', 'url', 'app'} Try / catch
No catch needed; correct the caller to send channel/url/app only.
Prevention
- Target androidtv_remote entities only with channel/url/app play_media calls.
- Test automations against the integration's documented media types.
When it happens
Trigger: Calling play_media with media_content_type music, video, tvshow, playlist, etc. — types valid for other media_player integrations but unsupported by androidtv_remote.
Common situations: Generic media-browser scripts, YAML automations copied from another integration, or frontend cards sending standard media types to an Android TV remote entity.
Related errors
AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14).
Data as JSON: /api/errors/c67546a68ccff63f.
Report an issue: GitHub.