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

View File

@@ -52,7 +52,7 @@ class AmazonDevicesConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Alexa Devices.""" """Handle a config flow for Alexa Devices."""
VERSION = 1 VERSION = 1
MINOR_VERSION = 1 MINOR_VERSION = 2
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None 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"}, CONF_LOGIN_DATA: {"session": "test-session"},
}, },
unique_id=TEST_USERNAME, unique_id=TEST_USERNAME,
version=1,
minor_version=2,
) )

View File

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

View File

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