From 30c93248feeee55d3f16db55aec36dc9d0582506 Mon Sep 17 00:00:00 2001 From: virtualdj Date: Sat, 21 Dec 2024 20:25:41 +0000 Subject: [PATCH] Fix upgrade configurazione su HA precedenti a 2024.3.0 --- custom_components/pun_sensor/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/custom_components/pun_sensor/__init__.py b/custom_components/pun_sensor/__init__.py index 606291d..740f4f2 100644 --- a/custom_components/pun_sensor/__init__.py +++ b/custom_components/pun_sensor/__init__.py @@ -186,7 +186,14 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> # Implementata zona per prezzi zonali new_data = {**config_entry.data} new_data[CONF_ZONA] = DEFAULT_ZONA.name - hass.config_entries.async_update_entry(config_entry, data=new_data, version=2) + + if AwesomeVersion(HA_VERSION) >= AwesomeVersion("2024.3.0"): + hass.config_entries.async_update_entry( + config_entry, data=new_data, version=2 + ) + else: + # Le release precedenti ad HA 2024.3.0 non supportano la versione + hass.config_entries.async_update_entry(config_entry, data=new_data) # Migrazione completata _LOGGER.debug(