From c1b47b88f2bdf560bec5435dd8e88a0b9536b5ea Mon Sep 17 00:00:00 2001
From: Erik Montnemery <erik@montnemery.com>
Date: Thu, 10 Aug 2023 18:24:47 +0200
Subject: [PATCH] Adjust utility_meter tests which create devices (#98212)

---
 tests/components/utility_meter/test_config_flow.py | 2 ++
 tests/components/utility_meter/test_sensor.py      | 1 +
 2 files changed, 3 insertions(+)

diff --git a/tests/components/utility_meter/test_config_flow.py b/tests/components/utility_meter/test_config_flow.py
index 88a77407c07..262dbf36306 100644
--- a/tests/components/utility_meter/test_config_flow.py
+++ b/tests/components/utility_meter/test_config_flow.py
@@ -277,6 +277,7 @@ async def test_change_device_source(hass: HomeAssistant) -> None:
 
     # Configure source entity 1 (with a linked device)
     source_config_entry_1 = MockConfigEntry()
+    source_config_entry_1.add_to_hass(hass)
     source_device_entry_1 = device_registry.async_get_or_create(
         config_entry_id=source_config_entry_1.entry_id,
         identifiers={("sensor", "identifier_test1")},
@@ -292,6 +293,7 @@ async def test_change_device_source(hass: HomeAssistant) -> None:
 
     # Configure source entity 2 (with a linked device)
     source_config_entry_2 = MockConfigEntry()
+    source_config_entry_2.add_to_hass(hass)
     source_device_entry_2 = device_registry.async_get_or_create(
         config_entry_id=source_config_entry_2.entry_id,
         identifiers={("sensor", "identifier_test2")},
diff --git a/tests/components/utility_meter/test_sensor.py b/tests/components/utility_meter/test_sensor.py
index 3d2d95fd26f..b8f197a4dee 100644
--- a/tests/components/utility_meter/test_sensor.py
+++ b/tests/components/utility_meter/test_sensor.py
@@ -1466,6 +1466,7 @@ async def test_device_id(hass: HomeAssistant) -> None:
     entity_registry = er.async_get(hass)
 
     source_config_entry = MockConfigEntry()
+    source_config_entry.add_to_hass(hass)
     source_device_entry = device_registry.async_get_or_create(
         config_entry_id=source_config_entry.entry_id,
         identifiers={("sensor", "identifier_test")},
-- 
GitLab