Home Assistant Device Registry#
The device registry is where Home Assistant tracks all devices. Each device is represented by one or more entities and is matched by its identifiers (domain + opaque ID tuples) or connections (e.g., MAC address). A device entry carries metadata such as manufacturer, model, sw_version, hw_version, configuration_url, and an optional via_device / via_device_id pointing to a parent/hub device.
Defining a Device: Two Paths#
| Path | When to use |
|---|---|
Entity device_info property | Entity is loaded via a config entry and has a unique_id. HA reads _attr_device_info at entity-add time. |
device_registry.async_get_or_create() | Registering a hub or gateway that has no entities of its own. |
Both paths accept the same DeviceInfo TypedDict keys.
via_device vs. via_device_id β Deprecation#
| Field | Type | Status |
|---|---|---|
via_device | tuple[str, str] β (domain, identifier) | Deprecated as of HA 2026.9; removed in HA 2027.8 |
via_device_id | str β internal device registry ID | Current |
ATTR_VIA_DEVICE constant | homeassistant.const | Deprecated alongside via_device; removed in HA 2027.8 |
via_device was a convenience that let integrations reference a parent device by domain + external identifier. HA now requires the internal device.id string (via_device_id) instead.
StromerEntity and Device Registration#
Base entity (entity.py)#
StromerEntity is the base class for all Stromer platform entities. In __init__, it builds _attr_device_info via DeviceInfo(...) with these fields :
| Field | Source |
|---|---|
identifiers | {(DOMAIN, str(coordinator.data.bike_id))} |
manufacturer | "Stromer" |
model | bikedata["bike_model"] |
name | bikedata["bike_name"] |
sw_version | bikedata["suiversion"] |
hw_version | bikedata["tntversion"] |
After the constructor, it calls _attr_device_info.update({ATTR_NAME: ...}) to set the bike name. The ATTR_VIA_DEVICE: None entry and its import have been removed from entity.py, so device info no longer sets via_device. Previously this entry was a no-op (no parent device exists) that triggered HA's deprecation warning in 2026.9+ across every platform inheriting from StromerEntity (binary_sensor, button, sensor, switch).
Integration-level registration (__init__.py)#
During async_setup_entry, the integration manually registers the bike device and immediately calls async_update_device(..., via_device_id=None) to clear any stale via_device relationship left from earlier versions. This explicit nullification was introduced in v0.4.0 to clean up the "Connected to" field in the device page.
Key Files#
| File | Role |
|---|---|
custom_components/stromer/entity.py | Base StromerEntity β DeviceInfo construction |
custom_components/stromer/__init__.py | Manual device registration + via_device_id cleanup |
| HA Developer Docs: Device registry | Canonical reference for DeviceInfo fields and registry APIs |
Resolved Issue#
#329 β Deprecation notices related to via_device (opened 2026-09-08): HA 2026.9.0 logs deprecation warnings for ATTR_VIA_DEVICE usage and the via_device parameter in async_get_or_create, which breaks in HA 2027.8. Resolved by removing ATTR_VIA_DEVICE: None and its import from entity.py (PR #330).