{"record":{"id":"f6e9d924cedb6b64","repo":"home-assistant/core","slug":"invalid-device-id","errorCode":"invalid_device_id","errorMessage":"Invalid device ID specified: {device_id}","messagePattern":"Invalid device ID specified: (.+?)","errorType":"validation","errorClass":"ServiceValidationError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/alexa_devices/services.py","lineNumber":52,"sourceCode":"        vol.Required(ATTR_INFO_SKILL): cv.string,\n        vol.Required(ATTR_DEVICE_ID): cv.string,\n    }\n)\n\n\n@callback\ndef async_get_entry_id_for_service_call(\n    call: ServiceCall,\n) -> tuple[dr.DeviceEntry, AmazonConfigEntry]:\n    \"\"\"Get the entry ID related to a service call (by device ID).\"\"\"\n    device_registry = dr.async_get(call.hass)\n    device_id = call.data[ATTR_DEVICE_ID]\n    if (\n        device_entry := device_registry.async_get(\n            device_id, include_child_devices=False\n        )\n    ) is None:\n        raise ServiceValidationError(\n            translation_domain=DOMAIN,\n            translation_key=\"invalid_device_id\",\n            translation_placeholders={\"device_id\": device_id},\n        )\n\n    for entry_id in device_entry.config_entries:\n        if (entry := call.hass.config_entries.async_get_entry(entry_id)) is None:\n            continue\n        if entry.domain == DOMAIN:\n            if entry.state is not ConfigEntryState.LOADED:\n                raise ServiceValidationError(\n                    translation_domain=DOMAIN,\n                    translation_key=\"entry_not_loaded\",\n                    translation_placeholders={\"entry\": entry.title},\n                )\n            return (device_entry, entry)\n\n    raise ServiceValidationError(","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/alexa_devices/services.py#L34-L70","documentation":"ServiceValidationError with translation key alexa_devices/invalid_device_id, raised by async_get_entry_id_for_service_call when the device_id passed in a service call does not exist in the Home Assistant device registry. It is a user-input error shown in the UI/service response, not a crash.","triggerScenarios":"Calling any alexa_devices service (e.g. send_sound_notification, text command) with a device_id that is absent from dr.async_get(hass) — typos, deleted devices, or a device_id from another HA instance.","commonSituations":"Stale automations/scripts referencing a removed Alexa device, copy-paste of entity UUIDs instead of device_ids, or restored-from-backup automations pointing at registry entries that no longer exist.","solutions":["Open the Alexa device page in the UI and copy its real device_id (or pick it via the UI selector)","Update the automation/script to use the current device_id of the target Echo device","Remove the automation step entirely if the device was decommissioned","Restart or reload alexa_devices so newly added devices are registered before being referenced"],"exampleFix":"// before\naction:\n  domain: alexa_devices\n  data:\n    device_id: \"old-or-typo-id\"\n// after\naction:\n  domain: alexa_devices\n  data:\n    device_id: \"<device_id from Developer Tools > States / device page>\"","handlingStrategy":"validation","validationCode":"device_registry = dr.async_get(hass)\nif device_registry.async_get(device_id, include_child_devices=False) is None:\n    # do not call the service; log and skip\n    _LOGGER.warning(\"Unknown device_id: %s\", device_id)\n    return","typeGuard":null,"tryCatchPattern":"try:\n    await hass.services.async_call(DOMAIN, SERVICE, service_data, blocking=True)\nexcept ServiceValidationError as err:\n    if err.translation_key == \"invalid_device_id\":\n        _LOGGER.warning(\"Bad device_id in call: %s\", err)","preventionTips":["Always select devices through UI selectors instead of hardcoding device_ids","After removing a device, grep automations/scripts for its device_id","When restoring from backup, re-verify hardcoded device_ids still exist"],"tags":["alexa-devices","service-call","device-registry","user-input","homeassistant"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}