{"record":{"id":"1b2fabdad5722d25","repo":"home-assistant/core","slug":"invalid-value","errorCode":"INVALID_VALUE","errorMessage":"failed to map input {media_input} to a media source on {entity.entity_id}","messagePattern":"failed to map input (.+?) to a media source on (.+?)","errorType":"exception","errorClass":"AlexaInvalidValueError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/alexa/handlers.py","lineNumber":625,"sourceCode":"    source_list = entity.attributes.get(media_player.ATTR_INPUT_SOURCE_LIST) or []\n    for source in source_list:\n        formatted_source = (\n            source.lower().replace(\"-\", \"\").replace(\"_\", \"\").replace(\" \", \"\")\n        )\n        media_input = media_input.lower().replace(\" \", \"\")\n        if (\n            formatted_source in Inputs.VALID_SOURCE_NAME_MAP\n            and formatted_source == media_input\n        ) or (\n            media_input.endswith(\"1\") and formatted_source == media_input.rstrip(\"1\")\n        ):\n            media_input = source\n            break\n    else:\n        msg = (\n            f\"failed to map input {media_input} to a media source on {entity.entity_id}\"\n        )\n        raise AlexaInvalidValueError(msg)\n\n    data: dict[str, Any] = {\n        ATTR_ENTITY_ID: entity.entity_id,\n        media_player.ATTR_INPUT_SOURCE: media_input,\n    }\n\n    await hass.services.async_call(\n        entity.domain,\n        media_player.SERVICE_SELECT_SOURCE,\n        data,\n        blocking=False,\n        context=context,\n    )\n\n    return directive.response()\n\n\n@HANDLERS.register((\"Alexa.Speaker\", \"AdjustVolume\"))","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/alexa/handlers.py#L607-L643","documentation":"When Alexa selects an input (e.g. 'HDMI 1'), the handler tries to map the spoken name to one of the media_player entity's source_list entries, comparing case-formatted names and also tolerating a trailing '1' (e.g. 'HDMI1' vs 'HDMI'). If no source matches, it raises AlexaInvalidValueError, which Alexa reports back as INVALID_VALUE.","triggerScenarios":"An Alexa.ChangeChannel/Input selection whose payload input name does not match any entry in the media_player entity's source_list attribute after case normalization or trailing-'1' stripping. Typical when the TV/AVR reports sources with vendor-specific names ('hdmi', 'Game', 'Input1') while Alexa sends 'HDMI 1'.","commonSituations":"Broadlink/Android TV/AVR integrations exposing source lists with nonstandard names; renaming inputs on the device; users adding a ModeController for inputs where the friendly labels differ from the raw source_list strings.","solutions":["Rename the media_player's sources so they match Alexa's spoken input names (e.g. 'HDMI 1', 'AV 1'), via the integration's source-list configuration or entity customization.","Expose inputs through an Alexa ModeController with modes whose friendly names equal the source_list entries.","Test with developer tools: check the entity's source_list attribute, then call media_player.select_source with the exact string Alexa sends."],"exampleFix":"# before: source_list = ['hdmi_1', 'game']\n# Alexa says 'HDMI 1' -> AlexaInvalidValueError\n\n# after: customize the entity so source_list entries match spoken names\nmedia_player:\n  - platform: ... \n# or rename on the device/integration to ['HDMI 1', 'Game']","handlingStrategy":"validation","validationCode":"def normalize(name: str) -> str:\n    return name.strip().lower()\n\nspoken = 'HDMI 1'\nsources = state.attributes.get('source_list', [])\nok = any(\n    normalize(s) == normalize(spoken)\n    or (spoken.endswith('1') and normalize(s) == normalize(spoken)[:-1])\n    for s in sources\n)\nif not ok:\n    # pick nearest or reject before Alexa call\n    ...","typeGuard":"def input_matches_source(spoken: str, source_list: list[str]) -> bool:\n    n = spoken.strip().lower()\n    return any(\n        s.strip().lower() == n or (n.endswith('1') and s.strip().lower() == n.rstrip('1'))\n        for s in source_list\n    )","tryCatchPattern":"try:\n    await process_directive(directive)\nexcept AlexaInvalidValueError:\n    _LOGGER.warning('Input %s not in source_list %s', media_input, entity.attributes.get('source_list'))","preventionTips":["Keep source_list names aligned with Alexa's spoken input vocabulary ('HDMI 1', not 'hdmi_1').","Test select_source with the exact Alexa string in developer tools before voice use.","After renaming sources, ask Alexa to rediscover devices."],"tags":["alexa","smart-home","media-player","source-mapping","invalid-value"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}