From 31126c29ec3908d8c18354841b5a5d6789de0c2c Mon Sep 17 00:00:00 2001 From: bj00rn Date: Tue, 5 Nov 2024 21:57:06 +0100 Subject: [PATCH] fix: handle case where version is None in migration --- custom_components/saleryd_hrv/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/saleryd_hrv/__init__.py b/custom_components/saleryd_hrv/__init__.py index ddcbc6f..b601e4e 100644 --- a/custom_components/saleryd_hrv/__init__.py +++ b/custom_components/saleryd_hrv/__init__.py @@ -40,7 +40,11 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Migrate config entry.""" - if entry.version == 1: + if entry.version is not None and entry.version > CONFIG_VERSION: + # This means the user has downgraded from a future version + return False + + if entry.version is None or entry.version == 1: new_data = entry.data.copy() new_data |= { CONF_ENABLE_MAINTENANCE_SETTINGS: False,