home-assistant/core · error · ServiceValidationError

invalid_device_id

invalid_device_id

Error message

Invalid device ID given.

What it means

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.

Source

Thrown at homeassistant/components/blue_current/services.py:34

        # When no charging card is provided, use no charging card
        # (BCU_APP = no charging card).
        vol.Optional(CHARGING_CARD_ID, default=BCU_APP): cv.string,
    }
)


async def start_charge_session(service_call: ServiceCall) -> None:
    """Start a charge session with the provided device and charge card ID."""
    # When no charge card is provided, use the default charge card
    # set in the config flow.
    charging_card_id = service_call.data[CHARGING_CARD_ID]
    device_id = service_call.data[CONF_DEVICE_ID]

    # Get the device based on the given device ID.
    device = dr.async_get(service_call.hass).devices.get(device_id)

    if device is None:
        raise ServiceValidationError(
            translation_domain=DOMAIN, translation_key="invalid_device_id"
        )

    blue_current_config_entry: ConfigEntry | None = None

    for config_entry_id in device.config_entries:
        config_entry = service_call.hass.config_entries.async_get_entry(config_entry_id)
        if not config_entry or config_entry.domain != DOMAIN:
            # Not the blue_current config entry.
            continue

        if config_entry.state is not ConfigEntryState.LOADED:
            raise ServiceValidationError(
                translation_domain=DOMAIN, translation_key="config_entry_not_loaded"
            )

        blue_current_config_entry = config_entry
        break

View on GitHub (pinned to 58a3fdb3ea)

Solutions

  1. Use Developer Tools > Services/Actions, pick the device via the UI selector instead of typing an ID
  2. If hardcoding, re-fetch the current device_id from the device registry after re-adding the integration
  3. Pass the HA device_id (32-char hex), not the Blue Current evse_id or entity_id

Example fix

# before
service_data:
  device_id: 101.0SB0171_A1234
# after
service_data:
  device_id: 8f2c1a9d4e6b3f0a1c2d3e4f5a6b7c8d
Defensive patterns

Strategy: validation

Validate before calling

device = dr.async_get(hass).devices.get(device_id)
if device is None:
    raise ServiceValidationError(
        translation_domain=DOMAIN, translation_key="invalid_device_id"
    )

Type guard

def is_known_device(hass: HomeAssistant, device_id: str) -> bool:
    """True if device_id exists in the device registry."""
    return dr.async_get(hass).devices.get(device_id) is not None

Try / catch

try:
    await hass.services.async_call(
        DOMAIN, "start_charge_session",
        {CONF_DEVICE_ID: device_id, CHARGING_CARD_ID: card_id}, blocking=True,
    )
except HomeAssistantError as err:
    if "invalid_device_id" in str(err):
        _LOGGER.warning("Unknown device %s; refresh registry IDs", device_id)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14). Data as JSON: /api/errors/2b55b1d8f2195e35. Report an issue: GitHub.