Adapt esphome to new device registry API (#176942)

This commit is contained in:
Erik Montnemery
2026-07-28 18:27:12 +02:00
committed by GitHub
parent 1feb091f07
commit dd6aec6874
+6 -4
View File
@@ -121,13 +121,15 @@ def async_static_info_updated(
# Update device assignment in registry
if info.device_id:
# Entity now belongs to a sub device
new_device = dev_reg.async_get_device(
identifiers={(DOMAIN, f"{device_info.mac_address}_{info.device_id}")}
new_device = dev_reg.async_get_device_by_identifier(
(DOMAIN, f"{device_info.mac_address}_{info.device_id}"),
entry_data.entry_id,
)
else:
# Entity now belongs to the main device
new_device = dev_reg.async_get_device(
connections={(dr.CONNECTION_NETWORK_MAC, device_info.mac_address)}
new_device = dev_reg.async_get_device_by_connection(
(dr.CONNECTION_NETWORK_MAC, device_info.mac_address),
entry_data.entry_id,
)
if new_device: