mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Fix AirVisual exception when config entry contains old integration type (#47405)
This commit is contained in:
parent
972baa2ce4
commit
fa8ded5ad8
@ -39,6 +39,7 @@ from .const import (
|
|||||||
DATA_COORDINATOR,
|
DATA_COORDINATOR,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
INTEGRATION_TYPE_GEOGRAPHY_COORDS,
|
INTEGRATION_TYPE_GEOGRAPHY_COORDS,
|
||||||
|
INTEGRATION_TYPE_GEOGRAPHY_NAME,
|
||||||
INTEGRATION_TYPE_NODE_PRO,
|
INTEGRATION_TYPE_NODE_PRO,
|
||||||
LOGGER,
|
LOGGER,
|
||||||
)
|
)
|
||||||
@ -142,12 +143,21 @@ def _standardize_geography_config_entry(hass, config_entry):
|
|||||||
if not config_entry.options:
|
if not config_entry.options:
|
||||||
# If the config entry doesn't already have any options set, set defaults:
|
# If the config entry doesn't already have any options set, set defaults:
|
||||||
entry_updates["options"] = {CONF_SHOW_ON_MAP: True}
|
entry_updates["options"] = {CONF_SHOW_ON_MAP: True}
|
||||||
if CONF_INTEGRATION_TYPE not in config_entry.data:
|
if config_entry.data.get(CONF_INTEGRATION_TYPE) not in [
|
||||||
# If the config entry data doesn't contain the integration type, add it:
|
INTEGRATION_TYPE_GEOGRAPHY_COORDS,
|
||||||
entry_updates["data"] = {
|
INTEGRATION_TYPE_GEOGRAPHY_NAME,
|
||||||
**config_entry.data,
|
]:
|
||||||
CONF_INTEGRATION_TYPE: INTEGRATION_TYPE_GEOGRAPHY_COORDS,
|
# 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:
|
if not entry_updates:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user