Allow async_setup changes to config entry data be taken into a… (#34166)

* Allow async_setup changes to config entry data be taken into account

* Fix tests

* Limit scope try…finally

* Update tests/test_config_entries.py

Co-Authored-By: Martin Hjelmare <marhje52@gmail.com>

* Fix import

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Paulus SchoutsenandMartin Hjelmare authored and GitHub committed 2020-04-14 18:46:41 -07:00
1 parent 0db1fcca0f
commit 0b90ebf91e
10 files changed
+176 -33

No files matched your search

@@ -22,6 +22,7 @@ from homeassistant.helpers.event import async_track_time_interval
from .const import (
CONF_CITY,
CONF_COUNTRY,
CONF_GEOGRAPHIES,
DATA_CLIENT,
DEFAULT_SCAN_INTERVAL,
DOMAIN,
@@ -34,8 +35,6 @@ DATA_LISTENER = "listener"
DEFAULT_OPTIONS = {CONF_SHOW_ON_MAP: True}
CONF_GEOGRAPHIES = "geographies"
GEOGRAPHY_COORDINATES_SCHEMA = vol.Schema(
{
vol.Required(CONF_LATITUDE): cv.latitude,
@@ -158,8 +157,7 @@ async def async_migrate_entry(hass, config_entry):
# Update the config entry to only include the first geography (there is always
# guaranteed to be at least one):
data = {**config_entry.data}
geographies = data.pop(CONF_GEOGRAPHIES)
geographies = list(config_entry.data[CONF_GEOGRAPHIES])
first_geography = geographies.pop(0)
first_id = async_get_geography_id(first_geography)