home-assistant/core · error · ServiceValidationError
invalid_device_id
invalid_device_id
Error message
Invalid device ID specified: {device_id} What it means
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.
Source
Thrown at homeassistant/components/alexa_devices/services.py:52
vol.Required(ATTR_INFO_SKILL): cv.string,
vol.Required(ATTR_DEVICE_ID): cv.string,
}
)
@callback
def async_get_entry_id_for_service_call(
call: ServiceCall,
) -> tuple[dr.DeviceEntry, AmazonConfigEntry]:
"""Get the entry ID related to a service call (by device ID)."""
device_registry = dr.async_get(call.hass)
device_id = call.data[ATTR_DEVICE_ID]
if (
device_entry := device_registry.async_get(
device_id, include_child_devices=False
)
) is None:
raise ServiceValidationError(
translation_domain=DOMAIN,
translation_key="invalid_device_id",
translation_placeholders={"device_id": device_id},
)
for entry_id in device_entry.config_entries:
if (entry := call.hass.config_entries.async_get_entry(entry_id)) is None:
continue
if entry.domain == DOMAIN:
if entry.state is not ConfigEntryState.LOADED:
raise ServiceValidationError(
translation_domain=DOMAIN,
translation_key="entry_not_loaded",
translation_placeholders={"entry": entry.title},
)
return (device_entry, entry)
raise ServiceValidationError(View on GitHub (pinned to 58a3fdb3ea)
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
Example fix
// before
action:
domain: alexa_devices
data:
device_id: "old-or-typo-id"
// after
action:
domain: alexa_devices
data:
device_id: "<device_id from Developer Tools > States / device page>" Defensive patterns
Strategy: validation
Validate before calling
device_registry = dr.async_get(hass)
if device_registry.async_get(device_id, include_child_devices=False) is None:
# do not call the service; log and skip
_LOGGER.warning("Unknown device_id: %s", device_id)
return Try / catch
try:
await hass.services.async_call(DOMAIN, SERVICE, service_data, blocking=True)
except ServiceValidationError as err:
if err.translation_key == "invalid_device_id":
_LOGGER.warning("Bad device_id in call: %s", err) Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14).
Data as JSON: /api/errors/f6e9d924cedb6b64.
Report an issue: GitHub.