Skip to content

Commit

Permalink
refactor: maintenance update for 2024.3.x+ (#878)
Browse files Browse the repository at this point in the history
* refactor: maintenace update for 2024.3.x+

* more 2024.3 updates

* fix await
  • Loading branch information
firstof9 authored Mar 6, 2024
1 parent 7dcefe9 commit 6a684ae
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions custom_components/mail_and_packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b

config_entry.add_update_listener(update_listener)

config_entry.options = config_entry.data
hass.config_entries.async_update_entry(config_entry, options=config_entry.data)
config = config_entry.data

# Variables for data coordinator
Expand Down Expand Up @@ -183,10 +183,9 @@ async def async_migrate_entry(hass, config_entry):
updated_config[CONF_AMAZON_DAYS] = DEFAULT_AMAZON_DAYS

if updated_config != config_entry.data:
hass.config_entries.async_update_entry(config_entry, data=updated_config)

config_entry.version = 4
_LOGGER.debug("Migration to version %s complete", config_entry.version)
hass.config_entries.async_update_entry(
config_entry, data=updated_config, version=4
)

# 2 -> 4
if version == 2:
Expand All @@ -204,10 +203,9 @@ async def async_migrate_entry(hass, config_entry):
updated_config[CONF_AMAZON_DAYS] = DEFAULT_AMAZON_DAYS

if updated_config != config_entry.data:
hass.config_entries.async_update_entry(config_entry, data=updated_config)

config_entry.version = 4
_LOGGER.debug("Migration to version %s complete", config_entry.version)
hass.config_entries.async_update_entry(
config_entry, data=updated_config, version=4
)

if version == 3:
_LOGGER.debug("Migrating from version %s", version)
Expand All @@ -217,10 +215,11 @@ async def async_migrate_entry(hass, config_entry):
updated_config[CONF_AMAZON_DAYS] = DEFAULT_AMAZON_DAYS

if updated_config != config_entry.data:
hass.config_entries.async_update_entry(config_entry, data=updated_config)
hass.config_entries.async_update_entry(
config_entry, data=updated_config, version=4
)

config_entry.version = 4
_LOGGER.debug("Migration to version %s complete", config_entry.version)
_LOGGER.debug("Migration complete")

return True

Expand Down

0 comments on commit 6a684ae

Please sign in to comment.