{"record":{"id":"d7369177eff2611a","repo":"home-assistant/core","slug":"invalid-channel","errorCode":"invalid_channel","errorMessage":"Channel must be numeric: {media_id}","messagePattern":"Channel must be numeric: (.+?)","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/androidtv_remote/media_player.py","lineNumber":191,"sourceCode":"\n    @override\n    async def async_media_previous_track(self) -> None:\n        \"\"\"Send previous track command.\"\"\"\n        self._send_key_command(\"MEDIA_PREVIOUS\")\n\n    @override\n    async def async_media_next_track(self) -> None:\n        \"\"\"Send next track command.\"\"\"\n        self._send_key_command(\"MEDIA_NEXT\")\n\n    @override\n    async def async_play_media(\n        self, media_type: MediaType | str, media_id: str, **kwargs: Any\n    ) -> None:\n        \"\"\"Play a piece of media.\"\"\"\n        if media_type == MediaType.CHANNEL:\n            if not media_id.isnumeric():\n                raise HomeAssistantError(\n                    translation_domain=DOMAIN,\n                    translation_key=\"invalid_channel\",\n                    translation_placeholders={\"media_id\": media_id},\n                )\n            if self._channel_set_task:\n                self._channel_set_task.cancel()\n            self._channel_set_task = asyncio.create_task(\n                self._send_key_commands(list(media_id))\n            )\n            await self._channel_set_task\n            return\n\n        if media_type in [MediaType.URL, MediaType.APP]:\n            self._send_launch_app_command(media_id)\n            return\n\n        raise HomeAssistantError(\n            translation_domain=DOMAIN,","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/androidtv_remote/media_player.py#L173-L209","documentation":"Raised as HomeAssistantError (translation invalid_channel) when play_media is called with media_type CHANNEL but media_id.isnumeric() is false. The Android TV remote channel feature works by sending each digit as a key press, so a non-numeric channel (e.g. a channel name or URL) cannot be sent. This is pure input validation and no command reaches the device.","triggerScenarios":"A service call like media_player.play_media with media_content_type: channel and media_content_id: 'BBC One' or '5.1' — anything containing non-digit characters fails the isnumeric check.","commonSituations":"Automations or scripts written for a different integration (e.g. Roku/TV card) reusing channel names; decimals like '5.1'; users pasting call signs instead of numbers.","solutions":["Pass only digits, e.g. '101' not 'Channel 101' or '101.1'.","For non-numeric targets, launch the channel's app instead (media_type app with a deep link).","Fix the source automation/template that builds media_id."],"exampleFix":"// before\naction: androidtv_remote.play_media\ndata:\n  media_content_type: channel\n  media_content_id: \"HBO HD\"\n// after\naction: androidtv_remote.play_media\ndata:\n  media_content_type: channel\n  media_content_id: \"501\"","handlingStrategy":"validation","validationCode":"media_id = '501'\nassert media_type != 'channel' or media_id.isnumeric(), 'channel media_id must be digits only'","typeGuard":"def is_valid_channel(media_id: str) -> bool:\n    return media_id.isnumeric()","tryCatchPattern":"Not a catch case — a HomeAssistantError shown to the caller; validate media_id before the service call.","preventionTips":["Send channel numbers as pure digit strings.","Use app deep links for named content instead of channel strings."],"tags":["validation","media-player","androidtv","user-input"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}