From e5aa33502cc3601cd3782e3dcd7f868400aa8816 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Sun, 2 Aug 2026 10:42:42 +0200 Subject: [PATCH] Remove met device cleanup (#177966) --- homeassistant/components/met/__init__.py | 19 +--------------- tests/components/met/test_init.py | 28 ------------------------ tests/components/met/test_weather.py | 2 +- 3 files changed, 2 insertions(+), 47 deletions(-) diff --git a/homeassistant/components/met/__init__.py b/homeassistant/components/met/__init__.py index f8305094b810..05a7fb988245 100644 --- a/homeassistant/components/met/__init__.py +++ b/homeassistant/components/met/__init__.py @@ -4,14 +4,8 @@ import logging from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from homeassistant.helpers import device_registry as dr -from .const import ( - CONF_TRACK_HOME, - DEFAULT_HOME_LATITUDE, - DEFAULT_HOME_LONGITUDE, - DOMAIN, -) +from .const import CONF_TRACK_HOME, DEFAULT_HOME_LATITUDE, DEFAULT_HOME_LONGITUDE from .coordinator import MetDataUpdateCoordinator, MetWeatherConfigEntry PLATFORMS = [Platform.WEATHER] @@ -49,8 +43,6 @@ async def async_setup_entry( await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS) - await cleanup_old_device(hass) - return True @@ -59,12 +51,3 @@ async def async_unload_entry( ) -> bool: """Unload a config entry.""" return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS) - - -async def cleanup_old_device(hass: HomeAssistant) -> None: - """Cleanup device without proper device identifier.""" - device_reg = dr.async_get(hass) - device = device_reg.async_get_device(identifiers={(DOMAIN,)}) # type: ignore[arg-type] - if device: - _LOGGER.debug("Removing improper device %s", device.name) - device_reg.async_remove_device(device.id) diff --git a/tests/components/met/test_init.py b/tests/components/met/test_init.py index 54f6930513b9..08f9650e331b 100644 --- a/tests/components/met/test_init.py +++ b/tests/components/met/test_init.py @@ -10,7 +10,6 @@ from homeassistant.components.met.const import ( from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant from homeassistant.core_config import async_process_ha_core_config -from homeassistant.helpers import device_registry as dr from . import init_integration @@ -50,30 +49,3 @@ async def test_fail_default_home_entry( "Skip setting up met.no integration; No Home location has been set" in caplog.text ) - - -async def test_removing_incorrect_devices( - hass: HomeAssistant, - device_registry: dr.DeviceRegistry, - caplog: pytest.LogCaptureFixture, - mock_weather, -) -> None: - """Test we remove incorrect devices.""" - entry = await init_integration(hass) - - device_registry.async_get_or_create( - config_entry_id=entry.entry_id, - name="Forecast_legacy", - entry_type=dr.DeviceEntryType.SERVICE, - identifiers={(DOMAIN,)}, - manufacturer="Met.no", - model="Forecast", - configuration_url="https://www.met.no/en", - ) - - assert await hass.config_entries.async_reload(entry.entry_id) - assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - - assert not device_registry.async_get_device(identifiers={(DOMAIN,)}) - assert device_registry.async_get_device(identifiers={(DOMAIN, entry.entry_id)}) - assert "Removing improper device Forecast_legacy" in caplog.text diff --git a/tests/components/met/test_weather.py b/tests/components/met/test_weather.py index 131457e867dd..a07e18b4f6a8 100644 --- a/tests/components/met/test_weather.py +++ b/tests/components/met/test_weather.py @@ -1,7 +1,7 @@ """Test Met weather entity.""" from homeassistant import config_entries -from homeassistant.components.met import DOMAIN +from homeassistant.components.met.const import DOMAIN from homeassistant.components.weather import ( ATTR_CONDITION_CLOUDY, ATTR_WEATHER_DEW_POINT,