Skip to content

Commit

Permalink
fix: Set config entry unique ID only using proper serial number
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Feb 9, 2025
1 parent cf81354 commit 1fd2627
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions custom_components/solarman/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ 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(f"solarman_{user_input[CONF_SERIAL]}")
self._abort_if_unique_id_configured() # self._abort_if_unique_id_configured(updates={CONF_HOST: url.host})
if (serial := user_input[CONF_SERIAL]):
await self.async_set_unique_id(f"solarman_{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)))

_LOGGER.debug(f"ConfigFlowHandler.async_step_user: connection validation failed: {user_input}")
Expand Down

0 comments on commit 1fd2627

Please sign in to comment.