Skip to content

Commit

Permalink
fix: Integration has an invalid unique_id of type int when a string i…
Browse files Browse the repository at this point in the history
…s expected
  • Loading branch information
davidrapan committed Dec 27, 2024
1 parent 0654cbd commit e4ad4cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custom_components/solarman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions custom_components/solarman/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)))

Expand Down

0 comments on commit e4ad4cb

Please sign in to comment.