diff --git a/tests/components/template/test_binary_sensor.py b/tests/components/template/test_binary_sensor.py index ab74e4dec0d..50cad5be9e1 100644 --- a/tests/components/template/test_binary_sensor.py +++ b/tests/components/template/test_binary_sensor.py @@ -1405,10 +1405,12 @@ async def test_trigger_entity_restore_state_auto_off_expired( assert state.state == OFF -async def test_device_id(hass: HomeAssistant) -> None: +async def test_device_id( + hass: HomeAssistant, + device_registry: dr.DeviceRegistry, + entity_registry: er.EntityRegistry, +) -> None: """Test for device for Template.""" - device_registry = dr.async_get(hass) - entity_registry = er.async_get(hass) device_config_entry = MockConfigEntry() device_config_entry.add_to_hass(hass) diff --git a/tests/components/template/test_config_flow.py b/tests/components/template/test_config_flow.py index 40f0c2da0e8..f277b918661 100644 --- a/tests/components/template/test_config_flow.py +++ b/tests/components/template/test_config_flow.py @@ -143,11 +143,10 @@ async def test_config_flow_device( hass: HomeAssistant, template_type: str, state_template: str, + device_registry: dr.DeviceRegistry, ) -> None: """Test remove the device registry configuration entry when the device changes.""" - device_registry = dr.async_get(hass) - # Configure a device registry entry_device = MockConfigEntry() entry_device.add_to_hass(hass) @@ -960,11 +959,10 @@ async def test_options_flow_change_device( hass: HomeAssistant, template_type: str, state_template: str, + device_registry: dr.DeviceRegistry, ) -> None: """Test remove the device registry configuration entry when the device changes.""" - device_registry = dr.async_get(hass) - # Configure a device registry entry_device1 = MockConfigEntry() entry_device1.add_to_hass(hass) diff --git a/tests/components/template/test_init.py b/tests/components/template/test_init.py index 0b2ed873a9c..d13fd9035b0 100644 --- a/tests/components/template/test_init.py +++ b/tests/components/template/test_init.py @@ -271,11 +271,12 @@ async def async_yaml_patch_helper(hass, filename): await hass.async_block_till_done() -async def test_change_device(hass: HomeAssistant) -> None: +async def test_change_device( + hass: HomeAssistant, + device_registry: dr.DeviceRegistry, +) -> None: """Test remove the device registry configuration entry when the device changes.""" - device_registry = dr.async_get(hass) - # Configure a device registry entry_device1 = MockConfigEntry() entry_device1.add_to_hass(hass) diff --git a/tests/components/template/test_sensor.py b/tests/components/template/test_sensor.py index 53c31c680dd..37d6d120491 100644 --- a/tests/components/template/test_sensor.py +++ b/tests/components/template/test_sensor.py @@ -1898,9 +1898,12 @@ async def test_trigger_action( assert events[0].context.parent_id == context.id -async def test_device_id(hass: HomeAssistant) -> None: +async def test_device_id( + hass: HomeAssistant, + device_registry: dr.DeviceRegistry, + entity_registry: er.EntityRegistry, +) -> None: """Test for device for Template.""" - device_registry = dr.async_get(hass) device_config_entry = MockConfigEntry() device_config_entry.add_to_hass(hass) @@ -1929,7 +1932,6 @@ async def test_device_id(hass: HomeAssistant) -> None: assert await hass.config_entries.async_setup(template_config_entry.entry_id) await hass.async_block_till_done() - entity_registry = er.async_get(hass) template_entity = entity_registry.async_get("sensor.my_template") assert template_entity is not None assert template_entity.device_id == device_entry.id