Fix async_migrate_entry for Alexa Devices (#151038)

This commit is contained in:
Simone Chemelli
2025-08-26 12:15:46 +02:00
committed by GitHub
parent 4c166c2320
commit 0031bce832
5 changed files with 11 additions and 9 deletions

View File

@@ -42,7 +42,7 @@ 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 and entry.minor_version == 0:
if entry.version == 1 and entry.minor_version == 1:
_LOGGER.debug(
"Migrating from version %s.%s", entry.version, entry.minor_version
)
@@ -56,12 +56,12 @@ async def async_migrate_entry(hass: HomeAssistant, entry: AmazonConfigEntry) ->
new_data.update({"site": f"https://www.amazon.{domain}"})
hass.config_entries.async_update_entry(
entry, data=new_data, version=1, minor_version=1
entry, data=new_data, version=1, minor_version=2
)
_LOGGER.info(
"Migration to version %s.%s successful", entry.version, entry.minor_version
)
_LOGGER.info(
"Migration to version %s.%s successful", entry.version, entry.minor_version
)
return True

View File

@@ -52,7 +52,7 @@ class AmazonDevicesConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Alexa Devices."""
VERSION = 1
MINOR_VERSION = 1
MINOR_VERSION = 2
async def async_step_user(
self, user_input: dict[str, Any] | None = None

View File

@@ -85,4 +85,6 @@ def mock_config_entry() -> MockConfigEntry:
CONF_LOGIN_DATA: {"session": "test-session"},
},
unique_id=TEST_USERNAME,
version=1,
minor_version=2,
)

View File

@@ -57,7 +57,7 @@
'discovery_keys': dict({
}),
'domain': 'alexa_devices',
'minor_version': 1,
'minor_version': 2,
'options': dict({
}),
'pref_disable_new_entities': False,

View File

@@ -49,7 +49,7 @@ async def test_migrate_entry(
},
unique_id=TEST_USERNAME,
version=1,
minor_version=0,
minor_version=1,
)
config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
@@ -57,5 +57,5 @@ async def test_migrate_entry(
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert config_entry.state is ConfigEntryState.LOADED
assert config_entry.minor_version == 1
assert config_entry.minor_version == 2
assert config_entry.data["site"] == f"https://www.amazon.{TEST_COUNTRY}"