From e4ad4cb3e0d8b1d43ac71dc515b5c3842e811b53 Mon Sep 17 00:00:00 2001 From: David Rapan Date: Fri, 27 Dec 2024 02:15:41 +0100 Subject: [PATCH] fix: Integration has an invalid unique_id of type int when a string is expected --- custom_components/solarman/__init__.py | 2 +- custom_components/solarman/config_flow.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/solarman/__init__.py b/custom_components/solarman/__init__.py index db585de..0d18fcd 100644 --- a/custom_components/solarman/__init__.py +++ b/custom_components/solarman/__init__.py @@ -104,7 +104,7 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> if not new_options.get(CONF_ADDITIONAL_OPTIONS): del new_options[CONF_ADDITIONAL_OPTIONS] - hass.config_entries.async_update_entry(config_entry, options = new_options, minor_version = ConfigFlowHandler.MINOR_VERSION, version = ConfigFlowHandler.VERSION) + hass.config_entries.async_update_entry(config_entry, unique_id = f"solarman_{new_data[CONF_SERIAL]}", options = new_options, minor_version = ConfigFlowHandler.MINOR_VERSION, version = ConfigFlowHandler.VERSION) _LOGGER.debug("Migration to configuration version %s.%s successful", config_entry.version, config_entry.minor_version) diff --git a/custom_components/solarman/config_flow.py b/custom_components/solarman/config_flow.py index 90c7321..69ee155 100644 --- a/custom_components/solarman/config_flow.py +++ b/custom_components/solarman/config_flow.py @@ -82,7 +82,7 @@ def remove_defaults(user_input: dict[str, Any]): return user_input class ConfigFlowHandler(ConfigFlow, domain = DOMAIN): - MINOR_VERSION = 5 + MINOR_VERSION = 6 VERSION = 1 async def async_step_user(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult: @@ -110,7 +110,7 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None) -> Con errors = {} if validate_connection(user_input, errors): - await self.async_set_unique_id(user_input[CONF_SERIAL]) + await self.async_set_unique_id(f"solarman_{user_input[CONF_SERIAL]}") self._abort_if_unique_id_configured() # self._abort_if_unique_id_configured(updates={CONF_HOST: url.host}) return self.async_create_entry(title = user_input[CONF_NAME], data = filter_by_keys(user_input, DATA_SCHEMA), options = remove_defaults(filter_by_keys(user_input, OPTS_SCHEMA)))