@@ -3210,6 +3210,76 @@ def async_create_entry( # type: ignore[override]
32103210
32113211 return result
32123212
3213+ @callback
3214+ def __async_update (
3215+ self ,
3216+ entry : ConfigEntry ,
3217+ * ,
3218+ unique_id : str | None | UndefinedType ,
3219+ title : str | UndefinedType ,
3220+ data : Mapping [str , Any ] | UndefinedType ,
3221+ data_updates : Mapping [str , Any ] | UndefinedType ,
3222+ options : Mapping [str , Any ] | UndefinedType ,
3223+ ) -> bool :
3224+ """Update config entry and return result.
3225+
3226+ Internal to be used by update_and_abort and update_reload_and_abort methods only.
3227+ """
3228+
3229+ if data_updates is not UNDEFINED :
3230+ if data is not UNDEFINED :
3231+ raise ValueError ("Cannot set both data and data_updates" )
3232+ data = entry .data | data_updates
3233+ return self .hass .config_entries .async_update_entry (
3234+ entry = entry ,
3235+ unique_id = unique_id ,
3236+ title = title ,
3237+ data = data ,
3238+ options = options ,
3239+ )
3240+
3241+ @callback
3242+ def async_update_and_abort (
3243+ self ,
3244+ entry : ConfigEntry ,
3245+ * ,
3246+ unique_id : str | None | UndefinedType = UNDEFINED ,
3247+ title : str | UndefinedType = UNDEFINED ,
3248+ data : Mapping [str , Any ] | UndefinedType = UNDEFINED ,
3249+ data_updates : Mapping [str , Any ] | UndefinedType = UNDEFINED ,
3250+ options : Mapping [str , Any ] | UndefinedType = UNDEFINED ,
3251+ reason : str | UndefinedType = UNDEFINED ,
3252+ ) -> ConfigFlowResult :
3253+ """Update config entry and finish config flow.
3254+
3255+ Args:
3256+ entry: config entry to update
3257+ unique_id: replace the unique_id of the entry
3258+ title: replace the title of the entry
3259+ data: replace the entry data with new data
3260+ data_updates: add items from data_updates to entry data - existing keys
3261+ are overridden
3262+ options: replace the entry options with new options
3263+ reason: set the reason for the abort, defaults to
3264+ `reauth_successful` or `reconfigure_successful` based on flow source
3265+
3266+ Returns:
3267+ ConfigFlowResult: The result of the config flow.
3268+ """
3269+ self .__async_update (
3270+ entry = entry ,
3271+ unique_id = unique_id ,
3272+ title = title ,
3273+ data = data ,
3274+ data_updates = data_updates ,
3275+ options = options ,
3276+ )
3277+ if reason is UNDEFINED :
3278+ reason = "reauth_successful"
3279+ if self .source == SOURCE_RECONFIGURE :
3280+ reason = "reconfigure_successful"
3281+ return self .async_abort (reason = reason )
3282+
32133283 @callback
32143284 def async_update_reload_and_abort (
32153285 self ,
@@ -3225,28 +3295,28 @@ def async_update_reload_and_abort(
32253295 ) -> ConfigFlowResult :
32263296 """Update config entry, reload config entry and finish config flow.
32273297
3228- :param data: replace the entry data with new data
3229- :param data_updates: add items from data_updates to entry data - existing keys
3230- are overridden
3231- :param options: replace the entry options with new options
3232- :param title: replace the title of the entry
3233- :param unique_id: replace the unique_id of the entry
3234-
3235- :param reason: set the reason for the abort, defaults to
3236- `reauth_successful` or `reconfigure_successful` based on flow source
3237-
3238- :param reload_even_if_entry_is_unchanged: set this to `False` if the entry
3239- should not be reloaded if it is unchanged
3298+ Args:
3299+ entry: config entry to update and reload
3300+ unique_id: replace the unique_id of the entry
3301+ title: replace the title of the entry
3302+ data: replace the entry data with new data
3303+ data_updates: add items from data_updates to entry data - existing keys
3304+ are overridden
3305+ options: replace the entry options with new options
3306+ reason: set the reason for the abort, defaults to
3307+ `reauth_successful` or `reconfigure_successful` based on flow source
3308+ reload_even_if_entry_is_unchanged: set this to `False` if the entry
3309+ should not be reloaded if it is unchanged
3310+
3311+ Returns:
3312+ ConfigFlowResult: The result of the config flow.
32403313 """
3241- if data_updates is not UNDEFINED :
3242- if data is not UNDEFINED :
3243- raise ValueError ("Cannot set both data and data_updates" )
3244- data = entry .data | data_updates
3245- result = self .hass .config_entries .async_update_entry (
3314+ result = self .__async_update (
32463315 entry = entry ,
32473316 unique_id = unique_id ,
32483317 title = title ,
32493318 data = data ,
3319+ data_updates = data_updates ,
32503320 options = options ,
32513321 )
32523322 if reload_even_if_entry_is_unchanged or result :
0 commit comments