{"record":{"id":"2b55b1d8f2195e35","repo":"home-assistant/core","slug":"invalid-device-id-2b55b1","errorCode":"invalid_device_id","errorMessage":"Invalid device ID given.","messagePattern":"Invalid device ID given\\.","errorType":"validation","errorClass":"ServiceValidationError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/blue_current/services.py","lineNumber":34,"sourceCode":"        # When no charging card is provided, use no charging card\n        # (BCU_APP = no charging card).\n        vol.Optional(CHARGING_CARD_ID, default=BCU_APP): cv.string,\n    }\n)\n\n\nasync def start_charge_session(service_call: ServiceCall) -> None:\n    \"\"\"Start a charge session with the provided device and charge card ID.\"\"\"\n    # When no charge card is provided, use the default charge card\n    # set in the config flow.\n    charging_card_id = service_call.data[CHARGING_CARD_ID]\n    device_id = service_call.data[CONF_DEVICE_ID]\n\n    # Get the device based on the given device ID.\n    device = dr.async_get(service_call.hass).devices.get(device_id)\n\n    if device is None:\n        raise ServiceValidationError(\n            translation_domain=DOMAIN, translation_key=\"invalid_device_id\"\n        )\n\n    blue_current_config_entry: ConfigEntry | None = None\n\n    for config_entry_id in device.config_entries:\n        config_entry = service_call.hass.config_entries.async_get_entry(config_entry_id)\n        if not config_entry or config_entry.domain != DOMAIN:\n            # Not the blue_current config entry.\n            continue\n\n        if config_entry.state is not ConfigEntryState.LOADED:\n            raise ServiceValidationError(\n                translation_domain=DOMAIN, translation_key=\"config_entry_not_loaded\"\n            )\n\n        blue_current_config_entry = config_entry\n        break","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/blue_current/services.py#L16-L52","documentation":"ServiceValidationError with translation key 'invalid_device_id' raised by Blue Current service handlers (e.g. start_charge_session) when the supplied CONF_DEVICE_ID does not resolve to a device in the Home Assistant device registry. The error is user-facing: the service call was made with an unknown/unregistered device_id.","triggerScenarios":"Calling the blue_current start_charge_session service with a device_id that is not in dr.async_get(hass).devices — typo, deleted device (integration removed then re-added generates new IDs), or a raw evse_id used instead of the HA device_id.","commonSituations":"Scripts hardcode device_ids, then the integration is re-created and registry IDs change; user pastes the charge point serial/evse_id instead of the HA device_id; device was deleted but script remains.","solutions":["Use Developer Tools > Services/Actions, pick the device via the UI selector instead of typing an ID","If hardcoding, re-fetch the current device_id from the device registry after re-adding the integration","Pass the HA device_id (32-char hex), not the Blue Current evse_id or entity_id"],"exampleFix":"# before\nservice_data:\n  device_id: 101.0SB0171_A1234\n# after\nservice_data:\n  device_id: 8f2c1a9d4e6b3f0a1c2d3e4f5a6b7c8d","handlingStrategy":"validation","validationCode":"device = dr.async_get(hass).devices.get(device_id)\nif device is None:\n    raise ServiceValidationError(\n        translation_domain=DOMAIN, translation_key=\"invalid_device_id\"\n    )","typeGuard":"def is_known_device(hass: HomeAssistant, device_id: str) -> bool:\n    \"\"\"True if device_id exists in the device registry.\"\"\"\n    return dr.async_get(hass).devices.get(device_id) is not None","tryCatchPattern":"try:\n    await hass.services.async_call(\n        DOMAIN, \"start_charge_session\",\n        {CONF_DEVICE_ID: device_id, CHARGING_CARD_ID: card_id}, blocking=True,\n    )\nexcept HomeAssistantError as err:\n    if \"invalid_device_id\" in str(err):\n        _LOGGER.warning(\"Unknown device %s; refresh registry IDs\", device_id)","preventionTips":["Use UI device selectors in automations instead of hardcoded IDs","After removing/re-adding the integration, update scripts with the new device_ids","Never pass evse_id or entity_id where device_id is expected"],"tags":["blue-current","service-validation","device-registry","service-call"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}