Followup async_migrate_entry fix for Alexa Devices (#151231)

This commit is contained in:
Simone Chemelli
2025-08-27 15:46:57 +02:00
committed by GitHub
parent d0deb16c10
commit 8f9167abbe
2 changed files with 7 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client, config_validation as cv from homeassistant.helpers import aiohttp_client, config_validation as cv
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from .const import _LOGGER, COUNTRY_DOMAINS, DOMAIN from .const import _LOGGER, CONF_LOGIN_DATA, COUNTRY_DOMAINS, DOMAIN
from .coordinator import AmazonConfigEntry, AmazonDevicesCoordinator from .coordinator import AmazonConfigEntry, AmazonDevicesCoordinator
from .services import async_setup_services from .services import async_setup_services
@@ -51,9 +51,9 @@ async def async_migrate_entry(hass: HomeAssistant, entry: AmazonConfigEntry) ->
country = entry.data[CONF_COUNTRY] country = entry.data[CONF_COUNTRY]
domain = COUNTRY_DOMAINS.get(country, country) domain = COUNTRY_DOMAINS.get(country, country)
# Save domain and remove country # Add site to login data
new_data = entry.data.copy() new_data = entry.data.copy()
new_data.update({"site": f"https://www.amazon.{domain}"}) new_data[CONF_LOGIN_DATA]["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=2 entry, data=new_data, version=1, minor_version=2

View File

@@ -58,4 +58,7 @@ 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 == 2 assert config_entry.minor_version == 2
assert config_entry.data["site"] == f"https://www.amazon.{TEST_COUNTRY}" assert (
config_entry.data[CONF_LOGIN_DATA]["site"]
== f"https://www.amazon.{TEST_COUNTRY}"
)