mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Migrate mqtt to lookup devices scoped to config entry (#177971)
This commit is contained in:
committed by
Bram Kragten
parent
d01f53fe77
commit
96edd60834
@@ -1319,8 +1319,8 @@ def ensure_via_device_exists(
|
||||
if (
|
||||
device_info is None
|
||||
or CONF_VIA_DEVICE not in device_info
|
||||
or (device_registry := dr.async_get(hass)).async_get_device(
|
||||
identifiers={device_info["via_device"]}
|
||||
or (device_registry := dr.async_get(hass)).async_get_device_by_identifier(
|
||||
device_info["via_device"], config_entry.entry_id
|
||||
)
|
||||
):
|
||||
return
|
||||
|
||||
@@ -36,8 +36,8 @@ class MQTTDeviceEntryMigration(RepairsFlow):
|
||||
"""Handle the confirm step of a fix flow."""
|
||||
if user_input is not None:
|
||||
device_registry = dr.async_get(self.hass)
|
||||
subentry_device = device_registry.async_get_device(
|
||||
identifiers={(DOMAIN, self.subentry_id)}
|
||||
subentry_device = device_registry.async_get_device_by_identifier(
|
||||
(DOMAIN, self.subentry_id), self.entry_id
|
||||
)
|
||||
entry = self.hass.config_entries.async_get_entry(self.entry_id)
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -53,7 +53,7 @@ from .common import (
|
||||
help_test_update_with_json_attrs_not_dict,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_mqtt_message
|
||||
from tests.common import async_fire_mqtt_message
|
||||
from tests.typing import MqttMockHAClientGenerator, MqttMockPahoClient
|
||||
|
||||
DEFAULT_CONFIG = {
|
||||
@@ -547,10 +547,9 @@ async def test_entity_device_info_with_hub(
|
||||
) -> None:
|
||||
"""Test MQTT event device registry integration."""
|
||||
await mqtt_mock_entry()
|
||||
other_config_entry = MockConfigEntry()
|
||||
other_config_entry.add_to_hass(hass)
|
||||
mqtt_config_entry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
hub = device_registry.async_get_or_create(
|
||||
config_entry_id=other_config_entry.entry_id,
|
||||
config_entry_id=mqtt_config_entry.entry_id,
|
||||
connections=set(),
|
||||
identifiers={("mqtt", "hub-id")},
|
||||
manufacturer="manufacturer",
|
||||
|
||||
@@ -76,7 +76,6 @@ from .common import (
|
||||
)
|
||||
|
||||
from tests.common import (
|
||||
MockConfigEntry,
|
||||
async_capture_events,
|
||||
async_fire_mqtt_message,
|
||||
async_fire_time_changed,
|
||||
@@ -1585,10 +1584,9 @@ async def test_entity_device_info_with_hub(
|
||||
) -> None:
|
||||
"""Test MQTT sensor device registry integration."""
|
||||
await mqtt_mock_entry()
|
||||
other_config_entry = MockConfigEntry()
|
||||
other_config_entry.add_to_hass(hass)
|
||||
mqtt_config_entry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
hub = device_registry.async_get_or_create(
|
||||
config_entry_id=other_config_entry.entry_id,
|
||||
config_entry_id=mqtt_config_entry.entry_id,
|
||||
connections=set(),
|
||||
identifiers={("mqtt", "hub-id")},
|
||||
manufacturer="manufacturer",
|
||||
|
||||
Reference in New Issue
Block a user