mirror of
https://github.com/home-assistant/core.git
synced 2026-12-04 12:50:45 -04:00
Pass a DeviceInfo to async_get_or_create_device in bluetooth, device_tracker, google_assistant and mqtt (#187571)
This commit is contained in:
@@ -338,14 +338,16 @@ async def async_update_device(
|
||||
device.id, new_connections=connections
|
||||
)
|
||||
break
|
||||
device_entry = device_registry.async_get_or_create(
|
||||
device_entry = device_registry.async_get_or_create_device(
|
||||
config_entry_id=entry.entry_id,
|
||||
name=adapter_human_name(adapter, address),
|
||||
connections=connections,
|
||||
manufacturer=details[ADAPTER_MANUFACTURER],
|
||||
model=adapter_model(details),
|
||||
sw_version=details.get(ADAPTER_SW_VERSION),
|
||||
hw_version=details.get(ADAPTER_HW_VERSION),
|
||||
device_info=dr.DeviceInfo(
|
||||
name=adapter_human_name(adapter, address),
|
||||
connections=connections,
|
||||
manufacturer=details[ADAPTER_MANUFACTURER],
|
||||
model=adapter_model(details),
|
||||
sw_version=details.get(ADAPTER_SW_VERSION),
|
||||
hw_version=details.get(ADAPTER_HW_VERSION),
|
||||
),
|
||||
)
|
||||
if via_device_id and (
|
||||
split_devices := device_registry.async_get_devices_for_composite_device_id(
|
||||
|
||||
@@ -723,11 +723,13 @@ class ScannerEntity(
|
||||
# Register our own device now that the tracked device is known to another
|
||||
# integration; matching the split of a pre-migration composite device prunes
|
||||
# the identifiers and connections copied from the composite.
|
||||
device_entry = dr.async_get(self.hass).async_get_or_create(
|
||||
device_entry = dr.async_get(self.hass).async_get_or_create_device(
|
||||
config_entry_id=self.platform.config_entry.entry_id,
|
||||
config_subentry_id=self.registry_entry.config_subentry_id,
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, self.mac_address)},
|
||||
name=self.hostname or self.mac_address,
|
||||
device_info=dr.DeviceInfo(
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, self.mac_address)},
|
||||
name=self.hostname or self.mac_address,
|
||||
),
|
||||
)
|
||||
|
||||
# Link the entity's registry entry to the device
|
||||
|
||||
@@ -138,13 +138,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: GoogleConfigEntry) -> No
|
||||
config.update(entry.data)
|
||||
|
||||
device_registry = dr.async_get(hass)
|
||||
device_registry.async_get_or_create(
|
||||
device_registry.async_get_or_create_device(
|
||||
config_entry_id=entry.entry_id,
|
||||
identifiers={(DOMAIN, config[CONF_PROJECT_ID])},
|
||||
manufacturer="Google",
|
||||
model="Google Assistant",
|
||||
name=config[CONF_PROJECT_ID],
|
||||
entry_type=dr.DeviceEntryType.SERVICE,
|
||||
device_info=dr.DeviceInfo(
|
||||
identifiers={(DOMAIN, config[CONF_PROJECT_ID])},
|
||||
manufacturer="Google",
|
||||
model="Google Assistant",
|
||||
name=config[CONF_PROJECT_ID],
|
||||
entry_type=dr.DeviceEntryType.SERVICE,
|
||||
),
|
||||
)
|
||||
|
||||
google_config = GoogleConfig(hass, config)
|
||||
|
||||
@@ -1441,9 +1441,9 @@ def ensure_via_device_exists(
|
||||
"Device Registry, creating new entry",
|
||||
identifier,
|
||||
)
|
||||
device_registry.async_get_or_create(
|
||||
device_registry.async_get_or_create_device(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
identifiers={identifier},
|
||||
device_info=dr.DeviceInfo(identifiers={identifier}),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user