diff --git a/custom_components/uk_bin_collection/__init__.py b/custom_components/uk_bin_collection/__init__.py index 4901900e80..d4e538cdba 100644 --- a/custom_components/uk_bin_collection/__init__.py +++ b/custom_components/uk_bin_collection/__init__.py @@ -28,6 +28,20 @@ async def async_setup(hass: HomeAssistant, config: dict) -> bool: _LOGGER.debug(f"{LOG_PREFIX} async_setup called with config: {config}") return True +async def async_migrate_entry(self, config_entry) -> bool: + """Migrate old config entries to new version.""" + if config_entry.version == 1: + _LOGGER.info(f"{LOG_PREFIX} Migrating config entry {config_entry.entry_id} from version 1 to 2.") + + # Example: Add default update_interval if not present + data = config_entry.data.copy() + data.setdefault("update_interval", 12) + + self.hass.config_entries.async_update_entry(config_entry, data=data) + config_entry.version = 2 + + _LOGGER.info(f"{LOG_PREFIX} Migration of config entry {config_entry.entry_id} successful.") + return True async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry