@@ -88,13 +88,16 @@ async def validate_input(
8888 user_input : MutableMapping [str , Any ],
8989 config_step : str ,
9090 errors : dict [str , Any ],
91+ expected_id : str | None = None ,
9192) -> dict [str , Any ]:
9293 """Check user input for errors."""
9394 # filtered_user_input: MutableMapping[str, Any] = {key: value for key, value in user_input.items() if key != CONF_PASSWORD}
9495 # _LOGGER.debug("[validate_input] user_input: %s", filtered_user_input)
9596
9697 try :
97- await _handle_user_input (hass = hass , user_input = user_input , config_step = config_step )
98+ await _handle_user_input (
99+ hass = hass , user_input = user_input , config_step = config_step , expected_id = expected_id
100+ )
98101 except BelowMinFirmware :
99102 _log_and_set_error (
100103 errors = errors ,
@@ -258,7 +261,10 @@ def _validate_firmware_version(firmware_version: str) -> None:
258261
259262
260263async def _handle_user_input (
261- hass : HomeAssistant , user_input : MutableMapping [str , Any ], config_step : str
264+ hass : HomeAssistant ,
265+ user_input : MutableMapping [str , Any ],
266+ config_step : str ,
267+ expected_id : str | None = None ,
262268) -> None :
263269 """Handle and validate the user input."""
264270 await _clean_and_parse_url (user_input )
@@ -305,7 +311,7 @@ async def _handle_user_input(
305311 if not user_input .get (CONF_NAME ):
306312 user_input [CONF_NAME ] = system_info .get ("name" ) or "OPNsense"
307313
308- user_input [CONF_DEVICE_UNIQUE_ID ] = await client .get_device_unique_id ()
314+ user_input [CONF_DEVICE_UNIQUE_ID ] = await client .get_device_unique_id (expected_id = expected_id )
309315 _LOGGER .debug ("[handle_user_input] Device Unique ID: %s" , user_input [CONF_DEVICE_UNIQUE_ID ])
310316
311317 if not user_input .get (CONF_DEVICE_UNIQUE_ID ):
@@ -562,7 +568,11 @@ async def async_step_granular_sync(
562568 self ._config .update (user_input )
563569 # _LOGGER.debug("[config_flow granular_sync] merged config: %s", self._config)
564570 errors = await validate_input (
565- hass = self .hass , user_input = self ._config , config_step = "granular_sync" , errors = errors
571+ hass = self .hass ,
572+ user_input = self ._config ,
573+ config_step = "granular_sync" ,
574+ errors = errors ,
575+ expected_id = self ._config .get (CONF_DEVICE_UNIQUE_ID ),
566576 )
567577 if not errors :
568578 return self .async_create_entry (
@@ -592,7 +602,11 @@ async def async_step_reconfigure(
592602 self ._config .update (user_input )
593603 # _LOGGER.debug("[config_flow reconfigure] merged config: %s", self._config)
594604 errors = await validate_input (
595- hass = self .hass , user_input = self ._config , config_step = "reconfigure" , errors = errors
605+ hass = self .hass ,
606+ user_input = self ._config ,
607+ config_step = "reconfigure" ,
608+ errors = errors ,
609+ expected_id = self ._config .get (CONF_DEVICE_UNIQUE_ID ),
596610 )
597611
598612 if not errors :
@@ -701,7 +715,11 @@ async def async_step_granular_sync(
701715 self ._config .update (user_input )
702716 # _LOGGER.debug("[options_flow granular_sync] merged user_input. config: %s. options: %s", self._config, self._options)
703717 errors = await validate_input (
704- hass = self .hass , user_input = self ._config , config_step = "granular_sync" , errors = errors
718+ hass = self .hass ,
719+ user_input = self ._config ,
720+ config_step = "granular_sync" ,
721+ errors = errors ,
722+ expected_id = self ._config .get (CONF_DEVICE_UNIQUE_ID ),
705723 )
706724 if not errors :
707725 if self ._options .get (CONF_DEVICE_TRACKER_ENABLED ):
0 commit comments