Fix AirVisual exception when config entry contains old integration type (#47405)
parent
972baa2ce4
commit
fa8ded5ad8
|
@ -39,6 +39,7 @@ from .const import (
|
|||
DATA_COORDINATOR,
|
||||
DOMAIN,
|
||||
INTEGRATION_TYPE_GEOGRAPHY_COORDS,
|
||||
INTEGRATION_TYPE_GEOGRAPHY_NAME,
|
||||
INTEGRATION_TYPE_NODE_PRO,
|
||||
LOGGER,
|
||||
)
|
||||
|
@ -142,12 +143,21 @@ def _standardize_geography_config_entry(hass, config_entry):
|
|||
if not config_entry.options:
|
||||
# If the config entry doesn't already have any options set, set defaults:
|
||||
entry_updates["options"] = {CONF_SHOW_ON_MAP: True}
|
||||
if CONF_INTEGRATION_TYPE not in config_entry.data:
|
||||
# If the config entry data doesn't contain the integration type, add it:
|
||||
entry_updates["data"] = {
|
||||
**config_entry.data,
|
||||
CONF_INTEGRATION_TYPE: INTEGRATION_TYPE_GEOGRAPHY_COORDS,
|
||||
}
|
||||
if config_entry.data.get(CONF_INTEGRATION_TYPE) not in [
|
||||
INTEGRATION_TYPE_GEOGRAPHY_COORDS,
|
||||
INTEGRATION_TYPE_GEOGRAPHY_NAME,
|
||||
]:
|
||||
# If the config entry data doesn't contain an integration type that we know
|
||||
# about, infer it from the data we have:
|
||||
entry_updates["data"] = {**config_entry.data}
|
||||
if CONF_CITY in config_entry.data:
|
||||
entry_updates["data"][
|
||||
CONF_INTEGRATION_TYPE
|
||||
] = INTEGRATION_TYPE_GEOGRAPHY_NAME
|
||||
else:
|
||||
entry_updates["data"][
|
||||
CONF_INTEGRATION_TYPE
|
||||
] = INTEGRATION_TYPE_GEOGRAPHY_COORDS
|
||||
|
||||
if not entry_updates:
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue