Migrate huawei_lte to use async_update_entry to alter config entries (#110309)

This commit is contained in:
J. Nick Koston 2024-02-12 01:28:54 -06:00 committed by GitHub
parent 73bb7d6830
commit 303bb99da0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -557,14 +557,12 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
recipient = options.get(CONF_RECIPIENT) recipient = options.get(CONF_RECIPIENT)
if isinstance(recipient, str): if isinstance(recipient, str):
options[CONF_RECIPIENT] = [x.strip() for x in recipient.split(",")] options[CONF_RECIPIENT] = [x.strip() for x in recipient.split(",")]
config_entry.version = 2 hass.config_entries.async_update_entry(config_entry, options=options, version=2)
hass.config_entries.async_update_entry(config_entry, options=options)
_LOGGER.info("Migrated config entry to version %d", config_entry.version) _LOGGER.info("Migrated config entry to version %d", config_entry.version)
if config_entry.version == 2: if config_entry.version == 2:
config_entry.version = 3
data = dict(config_entry.data) data = dict(config_entry.data)
data[CONF_MAC] = [] data[CONF_MAC] = []
hass.config_entries.async_update_entry(config_entry, data=data) hass.config_entries.async_update_entry(config_entry, data=data, version=3)
_LOGGER.info("Migrated config entry to version %d", config_entry.version) _LOGGER.info("Migrated config entry to version %d", config_entry.version)
# There can be no longer needed *_from_yaml data and options things left behind # There can be no longer needed *_from_yaml data and options things left behind
# from pre-2022.4ish; they can be removed while at it when/if we eventually bump and # from pre-2022.4ish; they can be removed while at it when/if we eventually bump and