diff --git a/homeassistant/components/airos/__init__.py b/homeassistant/components/airos/__init__.py index fca7b7c2405e..105ec10ce11b 100644 --- a/homeassistant/components/airos/__init__.py +++ b/homeassistant/components/airos/__init__.py @@ -116,10 +116,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: AirOSConfigEntry) -> boo async def async_migrate_entry(hass: HomeAssistant, entry: AirOSConfigEntry) -> bool: """Migrate old config entry.""" - # This means the user has downgraded from a future version - if entry.version > 2: - return False - # 1.1 Migrate config_entry to add advanced ssl settings if entry.version == 1 and entry.minor_version == 1: new_minor_version = 2 diff --git a/homeassistant/components/alexa_devices/__init__.py b/homeassistant/components/alexa_devices/__init__.py index b04be74029e6..894e18d82a74 100644 --- a/homeassistant/components/alexa_devices/__init__.py +++ b/homeassistant/components/alexa_devices/__init__.py @@ -65,10 +65,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: AmazonConfigEntry) -> bo async def async_migrate_entry(hass: HomeAssistant, entry: AmazonConfigEntry) -> bool: """Migrate old entry.""" - if entry.version > 1: - # This means the user has downgraded from a future version - return False - if entry.version == 1 and entry.minor_version < 3: if CONF_SITE in entry.data: # Site in data (wrong place), just move to login data diff --git a/homeassistant/components/anova/__init__.py b/homeassistant/components/anova/__init__.py index 8155807cb779..463c473db4d1 100644 --- a/homeassistant/components/anova/__init__.py +++ b/homeassistant/components/anova/__init__.py @@ -75,10 +75,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: AnovaConfigEntry) -> b """Migrate entry.""" _LOGGER.debug("Migrating from version %s:%s", entry.version, entry.minor_version) - if entry.version > 1: - # This means the user has downgraded from a future version - return False - if entry.version == 1 and entry.minor_version == 1: new_data = {**entry.data} if CONF_DEVICES in new_data: diff --git a/homeassistant/components/anthropic/__init__.py b/homeassistant/components/anthropic/__init__.py index 7ddddecb428c..3d7c3ce41386 100644 --- a/homeassistant/components/anthropic/__init__.py +++ b/homeassistant/components/anthropic/__init__.py @@ -178,10 +178,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: AnthropicConfigEntry) """Migrate entry.""" LOGGER.debug("Migrating from version %s:%s", entry.version, entry.minor_version) - if entry.version > 2: - # This means the user has downgraded from a future version - return False - if entry.version == 2 and entry.minor_version == 1: # Correct broken device migration in Home Assistant Core 2025.7.0b0-2025.7.0b1 device_registry = dr.async_get(hass) diff --git a/homeassistant/components/bsblan/__init__.py b/homeassistant/components/bsblan/__init__.py index 8cfd065c916e..6655ec11033d 100644 --- a/homeassistant/components/bsblan/__init__.py +++ b/homeassistant/components/bsblan/__init__.py @@ -230,10 +230,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: BSBLanConfigEntry) -> entry.minor_version, ) - if entry.version > 1: - # Downgraded from a future version; cannot migrate. - return False - # 1.1 -> 1.2: Add CONF_HEATING_CIRCUITS. Attempt to discover available # heating circuits from the device; fall back to [1] (pre-multi-circuit # default) if the device is unreachable or the endpoint is unsupported. diff --git a/homeassistant/components/comelit/__init__.py b/homeassistant/components/comelit/__init__.py index 9e7b4ee09912..ab7a1d3bd509 100644 --- a/homeassistant/components/comelit/__init__.py +++ b/homeassistant/components/comelit/__init__.py @@ -87,10 +87,6 @@ async def async_migrate_entry( ) -> bool: """Migrate old entry.""" - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1 and config_entry.minor_version == 1: device_registry = dr.async_get(hass) diff --git a/homeassistant/components/derivative/__init__.py b/homeassistant/components/derivative/__init__.py index a3bd88a38a2e..ce593e5f8f8c 100644 --- a/homeassistant/components/derivative/__init__.py +++ b/homeassistant/components/derivative/__init__.py @@ -54,10 +54,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> config_entry.minor_version, ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: if config_entry.minor_version < 2: new_options = {**config_entry.options} diff --git a/homeassistant/components/dnsip/__init__.py b/homeassistant/components/dnsip/__init__.py index a6d94bcf6f20..0242ec2eec08 100644 --- a/homeassistant/components/dnsip/__init__.py +++ b/homeassistant/components/dnsip/__init__.py @@ -111,10 +111,6 @@ async def async_migrate_entry( ) -> bool: """Migrate old entry to a newer version.""" - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version < 2 and config_entry.minor_version < 2: _LOGGER.debug( "Migrating configuration from version %s.%s", diff --git a/homeassistant/components/elevenlabs/__init__.py b/homeassistant/components/elevenlabs/__init__.py index 76d128818071..ef480e8ed492 100644 --- a/homeassistant/components/elevenlabs/__init__.py +++ b/homeassistant/components/elevenlabs/__init__.py @@ -98,10 +98,6 @@ async def async_migrate_entry( config_entry.minor_version, ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: new_options = {**config_entry.options} diff --git a/homeassistant/components/epson/__init__.py b/homeassistant/components/epson/__init__.py index 5bb31566a463..075227273563 100644 --- a/homeassistant/components/epson/__init__.py +++ b/homeassistant/components/epson/__init__.py @@ -88,10 +88,6 @@ async def async_migrate_entry( config_entry.minor_version, ) - if config_entry.version > 1 or config_entry.minor_version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1 and config_entry.minor_version == 1: new_data = {**config_entry.data} new_data[CONF_CONNECTION_TYPE] = HTTP diff --git a/homeassistant/components/file/__init__.py b/homeassistant/components/file/__init__.py index 53417cc25dd0..54b36b33c814 100644 --- a/homeassistant/components/file/__init__.py +++ b/homeassistant/components/file/__init__.py @@ -53,9 +53,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Migrate config entry.""" - if config_entry.version > 2: - # Downgraded from future - return False if config_entry.version < 2: # Move optional fields from data to options in config entry diff --git a/homeassistant/components/fujitsu_fglair/__init__.py b/homeassistant/components/fujitsu_fglair/__init__.py index 4396739fbfa0..0a20e494be88 100644 --- a/homeassistant/components/fujitsu_fglair/__init__.py +++ b/homeassistant/components/fujitsu_fglair/__init__.py @@ -48,8 +48,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: FGLairConfigEntry) -> b async def async_migrate_entry(hass: HomeAssistant, entry: FGLairConfigEntry) -> bool: """Migrate old entry.""" - if entry.version > 1: - return False if entry.version == 1: new_data = {**entry.data} diff --git a/homeassistant/components/fyta/__init__.py b/homeassistant/components/fyta/__init__.py index 1d519ed3b83d..5fce8af990c8 100644 --- a/homeassistant/components/fyta/__init__.py +++ b/homeassistant/components/fyta/__init__.py @@ -65,10 +65,6 @@ async def async_migrate_entry( """Migrate old entry.""" _LOGGER.debug("Migrating from version %s", config_entry.version) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: if config_entry.minor_version < 2: new = {**config_entry.data} diff --git a/homeassistant/components/generic/__init__.py b/homeassistant/components/generic/__init__.py index 29da4e7ac6c3..f50d445a82db 100644 --- a/homeassistant/components/generic/__init__.py +++ b/homeassistant/components/generic/__init__.py @@ -59,10 +59,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Migrate entry.""" _LOGGER.debug("Migrating from version %s:%s", entry.version, entry.minor_version) - if entry.version > 2: - # This means the user has downgraded from a future version - return False - if entry.version == 1: # Migrate to advanced section new_options = {**entry.options} diff --git a/homeassistant/components/generic_hygrostat/__init__.py b/homeassistant/components/generic_hygrostat/__init__.py index 624d0fb861b6..9af17b89c1ce 100644 --- a/homeassistant/components/generic_hygrostat/__init__.py +++ b/homeassistant/components/generic_hygrostat/__init__.py @@ -148,9 +148,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> "Migrating from version %s.%s", config_entry.version, config_entry.minor_version ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False if config_entry.version == 1: options = {**config_entry.options} if config_entry.minor_version < 2: diff --git a/homeassistant/components/generic_thermostat/__init__.py b/homeassistant/components/generic_thermostat/__init__.py index 991bc0d29035..e2e997b9c11b 100644 --- a/homeassistant/components/generic_thermostat/__init__.py +++ b/homeassistant/components/generic_thermostat/__init__.py @@ -76,9 +76,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> "Migrating from version %s.%s", config_entry.version, config_entry.minor_version ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False if config_entry.version == 1: options = {**config_entry.options} if config_entry.minor_version < 2: diff --git a/homeassistant/components/goodwe/__init__.py b/homeassistant/components/goodwe/__init__.py index abf95bd3a10e..8f8eda121397 100644 --- a/homeassistant/components/goodwe/__init__.py +++ b/homeassistant/components/goodwe/__init__.py @@ -98,10 +98,6 @@ async def async_migrate_entry( ) -> bool: """Migrate old config entries.""" - if config_entry.version > 2: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: # Update from version 1 to version 2 adding the PROTOCOL to the config entry host = config_entry.data[CONF_HOST] diff --git a/homeassistant/components/google_generative_ai_conversation/__init__.py b/homeassistant/components/google_generative_ai_conversation/__init__.py index 407ede0c3281..b3f0eb0ce829 100644 --- a/homeassistant/components/google_generative_ai_conversation/__init__.py +++ b/homeassistant/components/google_generative_ai_conversation/__init__.py @@ -226,10 +226,6 @@ async def async_migrate_entry( """Migrate entry.""" LOGGER.debug("Migrating from version %s:%s", entry.version, entry.minor_version) - if entry.version > 2: - # This means the user has downgraded from a future version - return False - if entry.version == 2 and entry.minor_version == 1: # Add TTS subentry which was missing in 2025.7.0b0 if not any( diff --git a/homeassistant/components/history_stats/__init__.py b/homeassistant/components/history_stats/__init__.py index 5af162fa29dc..1b95f09534e2 100644 --- a/homeassistant/components/history_stats/__init__.py +++ b/homeassistant/components/history_stats/__init__.py @@ -100,9 +100,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> "Migrating from version %s.%s", config_entry.version, config_entry.minor_version ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False if config_entry.version == 1: options = {**config_entry.options} if config_entry.minor_version < 2: diff --git a/homeassistant/components/homeassistant_connect_zbt2/__init__.py b/homeassistant/components/homeassistant_connect_zbt2/__init__.py index 166744eccc8b..64a022c1373f 100644 --- a/homeassistant/components/homeassistant_connect_zbt2/__init__.py +++ b/homeassistant/components/homeassistant_connect_zbt2/__init__.py @@ -108,10 +108,6 @@ async def async_migrate_entry( config_entry.minor_version, ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: if config_entry.minor_version == 1: serial_number = config_entry.data[SERIAL_NUMBER] diff --git a/homeassistant/components/homeassistant_sky_connect/__init__.py b/homeassistant/components/homeassistant_sky_connect/__init__.py index 16e2ce377ed4..142673d7e5b7 100644 --- a/homeassistant/components/homeassistant_sky_connect/__init__.py +++ b/homeassistant/components/homeassistant_sky_connect/__init__.py @@ -140,10 +140,6 @@ async def async_migrate_entry( "Migrating from version %s.%s", config_entry.version, config_entry.minor_version ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: if config_entry.minor_version == 1: # Add-on startup with type service get started before diff --git a/homeassistant/components/homematicip_cloud/__init__.py b/homeassistant/components/homematicip_cloud/__init__.py index 270d3e46af98..e18631c7049b 100644 --- a/homeassistant/components/homematicip_cloud/__init__.py +++ b/homeassistant/components/homematicip_cloud/__init__.py @@ -126,8 +126,6 @@ async def async_migrate_entry( hass: HomeAssistant, config_entry: config_entries.ConfigEntry ) -> bool: """Migrate the config entry from version 1 to version 2.""" - if config_entry.version > 2: - return False if config_entry.version == 1: _LOGGER.debug("Migrating HomematicIP Cloud config entry to version 2") diff --git a/homeassistant/components/integration/__init__.py b/homeassistant/components/integration/__init__.py index 1a4fab2a6fa2..eb8650dc6490 100644 --- a/homeassistant/components/integration/__init__.py +++ b/homeassistant/components/integration/__init__.py @@ -49,9 +49,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> "Migrating from version %s.%s", config_entry.version, config_entry.minor_version ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False if config_entry.version == 1: options = {**config_entry.options} if config_entry.minor_version < 2: diff --git a/homeassistant/components/islamic_prayer_times/__init__.py b/homeassistant/components/islamic_prayer_times/__init__.py index 2450d7e0b161..d0731bb693d5 100644 --- a/homeassistant/components/islamic_prayer_times/__init__.py +++ b/homeassistant/components/islamic_prayer_times/__init__.py @@ -52,9 +52,6 @@ async def async_migrate_entry( """Migrate old entry.""" _LOGGER.debug("Migrating from version %s", config_entry.version) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False if config_entry.version == 1: new = {**config_entry.data} if config_entry.minor_version < 2: diff --git a/homeassistant/components/jewish_calendar/__init__.py b/homeassistant/components/jewish_calendar/__init__.py index d68de2059741..5430647e7a02 100644 --- a/homeassistant/components/jewish_calendar/__init__.py +++ b/homeassistant/components/jewish_calendar/__init__.py @@ -131,10 +131,6 @@ async def async_migrate_entry( return {"new_unique_id": new_unique_id} return None - if config_entry.version > 2: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: await er.async_migrate_entries(hass, config_entry.entry_id, update_unique_id) hass.config_entries.async_update_entry(config_entry, version=2) diff --git a/homeassistant/components/lamarzocco/__init__.py b/homeassistant/components/lamarzocco/__init__.py index 10a8db33b126..b44228ad0f79 100644 --- a/homeassistant/components/lamarzocco/__init__.py +++ b/homeassistant/components/lamarzocco/__init__.py @@ -217,9 +217,6 @@ async def async_migrate_entry( hass: HomeAssistant, entry: LaMarzoccoConfigEntry ) -> bool: """Migrate config entry.""" - if entry.version > 4: - # guard against downgrade from a future version - return False if entry.version in (1, 2): _LOGGER.error( diff --git a/homeassistant/components/litterrobot/__init__.py b/homeassistant/components/litterrobot/__init__.py index 350c5f4fc06e..aa1144166898 100644 --- a/homeassistant/components/litterrobot/__init__.py +++ b/homeassistant/components/litterrobot/__init__.py @@ -48,9 +48,6 @@ async def async_migrate_entry( entry.minor_version, ) - if entry.version > 1: - return False - if entry.minor_version < 2: account = Account(websession=async_get_clientsession(hass)) try: diff --git a/homeassistant/components/mold_indicator/__init__.py b/homeassistant/components/mold_indicator/__init__.py index 5150927e4c00..d60b5f0c696d 100644 --- a/homeassistant/components/mold_indicator/__init__.py +++ b/homeassistant/components/mold_indicator/__init__.py @@ -99,10 +99,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> config_entry.minor_version, ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: if config_entry.minor_version < 2: # Remove the mold indicator config entry from the source device diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 47c6cf27bc24..619e32700772 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -467,10 +467,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: _LOGGER.debug("Migrating from version %s.%s", entry.version, entry.minor_version) data: dict[str, Any] = dict(entry.data) options: dict[str, Any] = dict(entry.options) - if entry.version > 2 or (entry.version == 2 and entry.minor_version > 1): - # This means the user has downgraded from a future version - # We allow read support for version 2.1 - return False if entry.version == 1 and entry.minor_version < 2: # Can be removed when the config entry is bumped to version 2.1 diff --git a/homeassistant/components/nina/__init__.py b/homeassistant/components/nina/__init__.py index 666fd3d10124..24feb44320b5 100644 --- a/homeassistant/components/nina/__init__.py +++ b/homeassistant/components/nina/__init__.py @@ -44,9 +44,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: NinaConfigEntry) -> bo minor_version = entry.minor_version _LOGGER.debug("Migrating from version %s.%s", version, minor_version) - if entry.version > 1: - # This means the user has downgraded from a future version - return False new_data: dict[str, Any] = {**entry.data, CONF_FILTERS: {}} diff --git a/homeassistant/components/nmap_tracker/__init__.py b/homeassistant/components/nmap_tracker/__init__.py index b10c854971c4..ad2d7aa3705b 100644 --- a/homeassistant/components/nmap_tracker/__init__.py +++ b/homeassistant/components/nmap_tracker/__init__.py @@ -116,10 +116,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: "Migrating configuration from version %s.%s", entry.version, entry.minor_version ) - if entry.version > 1: - # This means the user has downgraded from a future version - return False - if entry.version == 1: new_options = {**entry.options} if entry.minor_version < 2: diff --git a/homeassistant/components/ollama/__init__.py b/homeassistant/components/ollama/__init__.py index b0ad4d433414..3f2bbcba4a0b 100644 --- a/homeassistant/components/ollama/__init__.py +++ b/homeassistant/components/ollama/__init__.py @@ -236,10 +236,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: OllamaConfigEntry) -> """Migrate entry.""" _LOGGER.debug("Migrating from version %s:%s", entry.version, entry.minor_version) - if entry.version > 3: - # This means the user has downgraded from a future version - return False - if entry.version == 2 and entry.minor_version == 1: # Correct broken device migration in Home Assistant Core 2025.7.0b0-2025.7.0b1 device_registry = dr.async_get(hass) diff --git a/homeassistant/components/onedrive/__init__.py b/homeassistant/components/onedrive/__init__.py index 35ccf3d50836..01f048fb2f8d 100644 --- a/homeassistant/components/onedrive/__init__.py +++ b/homeassistant/components/onedrive/__init__.py @@ -133,9 +133,6 @@ async def _migrate_backup_files(client: OneDriveClient, backup_folder_id: str) - async def async_migrate_entry(hass: HomeAssistant, entry: OneDriveConfigEntry) -> bool: """Migrate old entry.""" - if entry.version > 1: - # This means the user has downgraded from a future version - return False if (version := entry.version) == 1 and (minor_version := entry.minor_version) == 1: _LOGGER.debug( diff --git a/homeassistant/components/open_router/__init__.py b/homeassistant/components/open_router/__init__.py index a28a082ce0ff..cc82a1648fa4 100644 --- a/homeassistant/components/open_router/__init__.py +++ b/homeassistant/components/open_router/__init__.py @@ -63,9 +63,6 @@ async def async_migrate_entry( """Migrate config entry.""" LOGGER.debug("Migrating from version %s.%s", entry.version, entry.minor_version) - if entry.version > 1 or (entry.version == 1 and entry.minor_version > 2): - return False - if entry.version == 1 and entry.minor_version < 2: for subentry in entry.subentries.values(): if CONF_WEB_SEARCH in subentry.data: diff --git a/homeassistant/components/openai_conversation/__init__.py b/homeassistant/components/openai_conversation/__init__.py index 97805bd82aa6..f34f88c2cae7 100644 --- a/homeassistant/components/openai_conversation/__init__.py +++ b/homeassistant/components/openai_conversation/__init__.py @@ -428,10 +428,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: OpenAIConfigEntry) -> """Migrate entry.""" LOGGER.debug("Migrating from version %s:%s", entry.version, entry.minor_version) - if entry.version > 2: - # This means the user has downgraded from a future version - return False - if entry.version == 2 and entry.minor_version == 1: # Correct broken device migration in Home Assistant Core 2025.7.0b0-2025.7.0b1 device_registry = dr.async_get(hass) diff --git a/homeassistant/components/overkiz/__init__.py b/homeassistant/components/overkiz/__init__.py index d32fae005e73..638c1183543b 100644 --- a/homeassistant/components/overkiz/__init__.py +++ b/homeassistant/components/overkiz/__init__.py @@ -201,8 +201,6 @@ async def async_migrate_entry( hass: HomeAssistant, entry: OverkizDataConfigEntry ) -> bool: """Migrate old entry.""" - if entry.version > 1: - return False if entry.version == 1 and entry.minor_version < 2: await _async_migrate_strenum_unique_ids(hass, entry) diff --git a/homeassistant/components/roborock/__init__.py b/homeassistant/components/roborock/__init__.py index 3f90360968cb..21a80d6f97cf 100644 --- a/homeassistant/components/roborock/__init__.py +++ b/homeassistant/components/roborock/__init__.py @@ -253,9 +253,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: RoborockConfigEntry) - entry.version, entry.minor_version, ) - if entry.version > 1: - # Downgrade from future version - return False # 1->2: Migrate from unique id as email address to unique id as rruid if entry.minor_version == 1: diff --git a/homeassistant/components/russound_rio/__init__.py b/homeassistant/components/russound_rio/__init__.py index e328372f242c..41381ea24836 100644 --- a/homeassistant/components/russound_rio/__init__.py +++ b/homeassistant/components/russound_rio/__init__.py @@ -115,9 +115,6 @@ async def async_migrate_entry( hass: HomeAssistant, config_entry: RussoundConfigEntry ) -> bool: """Migrate old entry.""" - if config_entry.version > 2: - # This means the user has downgraded from a future version - return False if config_entry.version == 1: ( diff --git a/homeassistant/components/satel_integra/__init__.py b/homeassistant/components/satel_integra/__init__.py index dc07df405dac..69ed6339f29e 100644 --- a/homeassistant/components/satel_integra/__init__.py +++ b/homeassistant/components/satel_integra/__init__.py @@ -121,10 +121,6 @@ async def async_migrate_entry( config_entry.minor_version, ) - if config_entry.version > 2: - # This means the user has downgraded from a future version - return False - # 1.2 Migrate subentries to include configured numbers to title if config_entry.version == 1 and config_entry.minor_version == 1: for subentry in config_entry.subentries.values(): diff --git a/homeassistant/components/scrape/__init__.py b/homeassistant/components/scrape/__init__.py index 740b80a54e33..97b149b54b46 100644 --- a/homeassistant/components/scrape/__init__.py +++ b/homeassistant/components/scrape/__init__.py @@ -153,10 +153,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ScrapeConfigEntry) -> bo async def async_migrate_entry(hass: HomeAssistant, entry: ScrapeConfigEntry) -> bool: """Migrate old entry.""" - if entry.version > 2: - # Don't migrate from future version - return False - if entry.version == 1: old_to_new_sensor_id = {} for sensor_config in entry.options[SENSOR_DOMAIN]: diff --git a/homeassistant/components/shelly/__init__.py b/homeassistant/components/shelly/__init__.py index c46e89fc55bd..73972330e6e2 100644 --- a/homeassistant/components/shelly/__init__.py +++ b/homeassistant/components/shelly/__init__.py @@ -134,8 +134,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_migrate_entry(hass: HomeAssistant, entry: ShellyConfigEntry) -> bool: """Migrate old config entries.""" - if entry.version > 1 or (entry.version == 1 and entry.minor_version > 3): - return False + if entry.minor_version < 3: # One-time flip of explicit Active scanning to Auto so existing # installs get the new battery-friendly default; Passive stays diff --git a/homeassistant/components/smhi/__init__.py b/homeassistant/components/smhi/__init__.py index a3cdd5d9a8f8..92eb957c627c 100644 --- a/homeassistant/components/smhi/__init__.py +++ b/homeassistant/components/smhi/__init__.py @@ -47,10 +47,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: SMHIConfigEntry) -> boo async def async_migrate_entry(hass: HomeAssistant, entry: SMHIConfigEntry) -> bool: """Migrate old entry.""" - if entry.version > 3: - # Downgrade from future version - return False - if entry.version == 1: new_data = { CONF_NAME: entry.data[CONF_NAME], diff --git a/homeassistant/components/solarlog/__init__.py b/homeassistant/components/solarlog/__init__.py index b1858f7d0696..f3f971360f9f 100644 --- a/homeassistant/components/solarlog/__init__.py +++ b/homeassistant/components/solarlog/__init__.py @@ -93,10 +93,6 @@ async def async_migrate_entry( """Migrate old entry.""" _LOGGER.debug("Migrating from version %s", config_entry.version) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: if config_entry.minor_version < 2: # migrate old entity unique id diff --git a/homeassistant/components/sql/__init__.py b/homeassistant/components/sql/__init__.py index c0e0498297ba..0c644e6d5c7f 100644 --- a/homeassistant/components/sql/__init__.py +++ b/homeassistant/components/sql/__init__.py @@ -108,10 +108,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Migrate old entry.""" _LOGGER.debug("Migrating from version %s.%s", entry.version, entry.minor_version) - if entry.version > 1: - # This means the user has downgraded from a future version - return False - if entry.version == 1: old_options = {**entry.options} new_data = {} diff --git a/homeassistant/components/statistics/__init__.py b/homeassistant/components/statistics/__init__.py index 2e1c2126cb4a..49dcb19ceb56 100644 --- a/homeassistant/components/statistics/__init__.py +++ b/homeassistant/components/statistics/__init__.py @@ -57,9 +57,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> "Migrating from version %s.%s", config_entry.version, config_entry.minor_version ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False if config_entry.version == 1: options = {**config_entry.options} if config_entry.minor_version < 2: diff --git a/homeassistant/components/suez_water/__init__.py b/homeassistant/components/suez_water/__init__.py index 2104b49fd70d..5ff9c3bca7ce 100644 --- a/homeassistant/components/suez_water/__init__.py +++ b/homeassistant/components/suez_water/__init__.py @@ -41,9 +41,6 @@ async def async_migrate_entry( config_entry.minor_version, ) - if config_entry.version > 2: - return False - if config_entry.version == 1: # Migrate to version 2 counter_id = config_entry.data.get(CONF_COUNTER_ID) diff --git a/homeassistant/components/swiss_public_transport/__init__.py b/homeassistant/components/swiss_public_transport/__init__.py index d564947d22b3..67706d6f8599 100644 --- a/homeassistant/components/swiss_public_transport/__init__.py +++ b/homeassistant/components/swiss_public_transport/__init__.py @@ -120,10 +120,6 @@ async def async_migrate_entry( """Migrate config entry.""" _LOGGER.debug("Migrating from version %s", config_entry.version) - if config_entry.version > 3: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1 and config_entry.minor_version == 1: # Remove wrongly registered devices and entries new_unique_id = unique_id_from_config(config_entry.data) diff --git a/homeassistant/components/switch_as_x/__init__.py b/homeassistant/components/switch_as_x/__init__.py index 93de0befa187..ef0a5cc5e3a0 100644 --- a/homeassistant/components/switch_as_x/__init__.py +++ b/homeassistant/components/switch_as_x/__init__.py @@ -81,9 +81,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> "Migrating from version %s.%s", config_entry.version, config_entry.minor_version ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False if config_entry.version == 1: options = {**config_entry.options} if config_entry.minor_version < 2: diff --git a/homeassistant/components/system_bridge/__init__.py b/homeassistant/components/system_bridge/__init__.py index 724498ab9a61..c2bf39f51732 100644 --- a/homeassistant/components/system_bridge/__init__.py +++ b/homeassistant/components/system_bridge/__init__.py @@ -28,7 +28,6 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue from homeassistant.helpers.typing import ConfigType -from .config_flow import SystemBridgeConfigFlow from .const import DATA_WAIT_TIMEOUT, DOMAIN, MODULES from .coordinator import SystemBridgeConfigEntry, SystemBridgeDataUpdateCoordinator from .services import async_setup_services @@ -215,9 +214,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> config_entry.minor_version, ) - if config_entry.version > SystemBridgeConfigFlow.VERSION: - return False - if config_entry.minor_version < 2: # Migrate to CONF_TOKEN, which was added in 1.2 new_data = dict(config_entry.data) diff --git a/homeassistant/components/systemmonitor/__init__.py b/homeassistant/components/systemmonitor/__init__.py index 25027048c72e..e26a69f1d059 100644 --- a/homeassistant/components/systemmonitor/__init__.py +++ b/homeassistant/components/systemmonitor/__init__.py @@ -74,10 +74,6 @@ async def async_migrate_entry( ) -> bool: """Migrate old entry.""" - if entry.version > 1: - # This means the user has downgraded from a future version - return False - if entry.version == 1 and entry.minor_version < 3: new_options = {**entry.options} if entry.minor_version == 1: diff --git a/homeassistant/components/tedee/__init__.py b/homeassistant/components/tedee/__init__.py index 38035f1dd11e..43cacb4cd652 100644 --- a/homeassistant/components/tedee/__init__.py +++ b/homeassistant/components/tedee/__init__.py @@ -134,9 +134,6 @@ async def async_migrate_entry( hass: HomeAssistant, config_entry: TedeeConfigEntry ) -> bool: """Migrate old entry.""" - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False version = config_entry.version minor_version = config_entry.minor_version diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index 2fdd009bcd2d..18c979b2f373 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -691,10 +691,6 @@ async def async_migrate_entry( minor_version, ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - # version 1.1: to add default API endpoint if version == 1 and minor_version == 1: new_data = {**config_entry.data} diff --git a/homeassistant/components/template/__init__.py b/homeassistant/components/template/__init__.py index 529560569d87..0907f6783904 100644 --- a/homeassistant/components/template/__init__.py +++ b/homeassistant/components/template/__init__.py @@ -163,10 +163,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> config_entry.minor_version, ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: if config_entry.minor_version < 2: # Remove the template config entry from the source device diff --git a/homeassistant/components/teslemetry/__init__.py b/homeassistant/components/teslemetry/__init__.py index eb99d2bb2bd1..0949be013258 100644 --- a/homeassistant/components/teslemetry/__init__.py +++ b/homeassistant/components/teslemetry/__init__.py @@ -453,9 +453,6 @@ async def async_migrate_entry( hass: HomeAssistant, config_entry: TeslemetryConfigEntry ) -> bool: """Migrate config entry.""" - if config_entry.version > 2: - # This means the user has downgraded from a future version - return False if config_entry.version == 1: access_token = config_entry.data[CONF_ACCESS_TOKEN] diff --git a/homeassistant/components/threshold/__init__.py b/homeassistant/components/threshold/__init__.py index 161acd0aa5bf..695d73859603 100644 --- a/homeassistant/components/threshold/__init__.py +++ b/homeassistant/components/threshold/__init__.py @@ -50,9 +50,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> "Migrating from version %s.%s", config_entry.version, config_entry.minor_version ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False if config_entry.version == 1: options = {**config_entry.options} if config_entry.minor_version < 2: diff --git a/homeassistant/components/tradfri/__init__.py b/homeassistant/components/tradfri/__init__.py index 018a0f3d375e..55c6c5ced34c 100644 --- a/homeassistant/components/tradfri/__init__.py +++ b/homeassistant/components/tradfri/__init__.py @@ -182,10 +182,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> config_entry.minor_version, ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: # Migrate to version 2 migrate_config_entry_and_identifiers(hass, config_entry) diff --git a/homeassistant/components/trafikverket_train/__init__.py b/homeassistant/components/trafikverket_train/__init__.py index 785b20760430..6afd125fd259 100644 --- a/homeassistant/components/trafikverket_train/__init__.py +++ b/homeassistant/components/trafikverket_train/__init__.py @@ -54,10 +54,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: TVTrainConfigEntry) -> """Migrate config entry.""" _LOGGER.debug("Migrating from version %s", entry.version) - if entry.version > 2: - # This means the user has downgraded from a future version - return False - if entry.version == 1: if entry.minor_version == 1: # Remove unique id diff --git a/homeassistant/components/trend/__init__.py b/homeassistant/components/trend/__init__.py index a7c4d7be0893..c5a8549e91c0 100644 --- a/homeassistant/components/trend/__init__.py +++ b/homeassistant/components/trend/__init__.py @@ -56,9 +56,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> "Migrating from version %s.%s", config_entry.version, config_entry.minor_version ) - if config_entry.version > 1: - # This means the user has downgraded from a future version - return False if config_entry.version == 1: options = {**config_entry.options} if config_entry.minor_version < 2: diff --git a/homeassistant/components/unifiprotect/__init__.py b/homeassistant/components/unifiprotect/__init__.py index 5d1886dc68bd..4d6b24e1768c 100644 --- a/homeassistant/components/unifiprotect/__init__.py +++ b/homeassistant/components/unifiprotect/__init__.py @@ -238,9 +238,6 @@ async def async_migrate_entry(hass: HomeAssistant, entry: UFPConfigEntry) -> boo """Migrate entry.""" _LOGGER.debug("Migrating configuration from version %s", entry.version) - if entry.version > 1: - return False - if entry.version == 1: options = dict(entry.options) if CONF_ALLOW_EA in options: diff --git a/homeassistant/components/utility_meter/__init__.py b/homeassistant/components/utility_meter/__init__.py index 6eebea8e6ba1..a0e2c77341c6 100644 --- a/homeassistant/components/utility_meter/__init__.py +++ b/homeassistant/components/utility_meter/__init__.py @@ -253,10 +253,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> "Migrating from version %s.%s", config_entry.version, config_entry.minor_version ) - if config_entry.version > 2: - # This means the user has downgraded from a future version - return False - if config_entry.version == 1: new = {**config_entry.options} new[CONF_METER_PERIODICALLY_RESETTING] = True diff --git a/homeassistant/components/vicare/__init__.py b/homeassistant/components/vicare/__init__.py index d72ae600d158..2df6790ae1c8 100644 --- a/homeassistant/components/vicare/__init__.py +++ b/homeassistant/components/vicare/__init__.py @@ -55,8 +55,6 @@ async def async_migrate_entry( hass: HomeAssistant, config_entry: ViCareConfigEntry ) -> bool: """Migrate old entry.""" - if config_entry.version > 2: - return False if config_entry.version == 1 and config_entry.minor_version < 2: _LOGGER.debug("Migrating ViCare config entry from version 1.1 to 1.2") diff --git a/homeassistant/components/vodafone_station/__init__.py b/homeassistant/components/vodafone_station/__init__.py index 3c8305e7fdef..317ba5d08aaf 100644 --- a/homeassistant/components/vodafone_station/__init__.py +++ b/homeassistant/components/vodafone_station/__init__.py @@ -38,10 +38,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) -> async def async_migrate_entry(hass: HomeAssistant, entry: VodafoneConfigEntry) -> bool: """Migrate old entry.""" - if entry.version > 1: - # This means the user has downgraded from a future version - return False - if entry.version == 1 and entry.minor_version == 1: _LOGGER.debug( "Migrating from version %s.%s", entry.version, entry.minor_version diff --git a/homeassistant/components/wled/__init__.py b/homeassistant/components/wled/__init__.py index 35868c072a30..a592720cd64d 100644 --- a/homeassistant/components/wled/__init__.py +++ b/homeassistant/components/wled/__init__.py @@ -81,10 +81,6 @@ async def async_migrate_entry( config_entry.minor_version, ) - if config_entry.version > 1: - # The user has downgraded from a future version - return False - if config_entry.version == 1: if config_entry.minor_version < 2: # 1.2: Normalize unique ID to be lowercase MAC address without separators. diff --git a/homeassistant/components/workday/__init__.py b/homeassistant/components/workday/__init__.py index 4f583425980b..29dc0094b42e 100644 --- a/homeassistant/components/workday/__init__.py +++ b/homeassistant/components/workday/__init__.py @@ -74,10 +74,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: WorkdayConfigEntry) -> async def async_migrate_entry(hass: HomeAssistant, entry: WorkdayConfigEntry) -> bool: """Migrate old config entry.""" - # This means the user has downgraded from a future version - if entry.version > 1: - return False - if entry.version == 1 and entry.minor_version == 1: # By keeping name in the data, it's enough to bump the minor version hass.config_entries.async_update_entry( diff --git a/homeassistant/components/zha/__init__.py b/homeassistant/components/zha/__init__.py index 99f745e4248b..388d22664ea2 100644 --- a/homeassistant/components/zha/__init__.py +++ b/homeassistant/components/zha/__init__.py @@ -33,7 +33,6 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.typing import ConfigType from . import homeassistant_hardware, repairs, websocket_api -from .config_flow import ZhaConfigFlowHandler from .const import ( CONF_BAUDRATE, CONF_CUSTOM_QUIRKS_PATH, @@ -310,10 +309,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> config_entry.minor_version, ) - if config_entry.version > ZhaConfigFlowHandler.VERSION: - # This means the user has downgraded from a future major version - return False - if config_entry.version == 1: data = { CONF_RADIO_TYPE: config_entry.data[CONF_RADIO_TYPE], diff --git a/tests/components/mqtt/test_config_flow.py b/tests/components/mqtt/test_config_flow.py index c2d1e9c8f9a5..dce672033c0c 100644 --- a/tests/components/mqtt/test_config_flow.py +++ b/tests/components/mqtt/test_config_flow.py @@ -2631,7 +2631,6 @@ async def test_migrate_config_entry( "options", ), [ - (2, 2, MOCK_ENTRY_DATA, MOCK_ENTRY_OPTIONS), (3, 1, MOCK_ENTRY_DATA, MOCK_ENTRY_OPTIONS), ], ) diff --git a/tests/components/shelly/test_init.py b/tests/components/shelly/test_init.py index a2c567299fdd..e5c49113173c 100644 --- a/tests/components/shelly/test_init.py +++ b/tests/components/shelly/test_init.py @@ -663,16 +663,9 @@ async def test_migrate_ble_scanner_mode( assert entry.options.get(CONF_BLE_SCANNER_MODE) == expected_mode -@pytest.mark.parametrize( - ("entry_version", "entry_minor_version"), - [(2, 1), (1, 4)], - ids=["future_major", "future_minor"], -) async def test_migrate_ble_scanner_mode_future_version( hass: HomeAssistant, mock_rpc_device: Mock, - entry_version: int, - entry_minor_version: int, ) -> None: """Future versions are not downgraded.""" entry = MockConfigEntry( @@ -686,16 +679,45 @@ async def test_migrate_ble_scanner_mode_future_version( unique_id=MOCK_MAC, options={CONF_BLE_SCANNER_MODE: BLEScannerMode.ACTIVE}, title="Test name", - version=entry_version, - minor_version=entry_minor_version, + version=2, + minor_version=1, ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done(wait_background_tasks=True) assert entry.state is ConfigEntryState.MIGRATION_ERROR - assert entry.version == entry_version - assert entry.minor_version == entry_minor_version + assert entry.version == 2 + assert entry.minor_version == 1 + assert entry.options[CONF_BLE_SCANNER_MODE] == BLEScannerMode.ACTIVE + + +async def test_migrate_ble_scanner_mode_future_minor_version( + hass: HomeAssistant, + mock_rpc_device: Mock, +) -> None: + """Future minor versions are not downgraded.""" + entry = MockConfigEntry( + domain=DOMAIN, + data={ + CONF_HOST: "192.168.1.37", + CONF_SLEEP_PERIOD: 0, + CONF_MODEL: MODEL_PLUS_2PM, + "gen": 2, + }, + unique_id=MOCK_MAC, + options={CONF_BLE_SCANNER_MODE: BLEScannerMode.ACTIVE}, + title="Test name", + version=1, + minor_version=4, + ) + entry.add_to_hass(hass) + await hass.config_entries.async_setup(entry.entry_id) + await hass.async_block_till_done(wait_background_tasks=True) + + assert entry.state is ConfigEntryState.LOADED + assert entry.version == 1 + assert entry.minor_version == 4 assert entry.options[CONF_BLE_SCANNER_MODE] == BLEScannerMode.ACTIVE