From 0120d000819a3f24f06d74e6fd8800067fe8bb32 Mon Sep 17 00:00:00 2001
From: "J. Nick Koston" <nick@koston.org>
Date: Fri, 26 Jan 2024 17:55:58 -1000
Subject: [PATCH] Switch unifiprotect to use async_update_reload_and_abort
 helper (#108934)

---
 homeassistant/components/unifiprotect/config_flow.py | 4 +---
 tests/components/unifiprotect/test_config_flow.py    | 3 ++-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/homeassistant/components/unifiprotect/config_flow.py b/homeassistant/components/unifiprotect/config_flow.py
index 1ca030ce48e..ec756118eb5 100644
--- a/homeassistant/components/unifiprotect/config_flow.py
+++ b/homeassistant/components/unifiprotect/config_flow.py
@@ -295,9 +295,7 @@ class ProtectFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
             # validate login data
             _, errors = await self._async_get_nvr_data(form_data)
             if not errors:
-                self.hass.config_entries.async_update_entry(self.entry, data=form_data)
-                await self.hass.config_entries.async_reload(self.entry.entry_id)
-                return self.async_abort(reason="reauth_successful")
+                return self.async_update_reload_and_abort(self.entry, data=form_data)
 
         self.context["title_placeholders"] = {
             "name": self.entry.title,
diff --git a/tests/components/unifiprotect/test_config_flow.py b/tests/components/unifiprotect/test_config_flow.py
index 854109bee6d..6af636ef448 100644
--- a/tests/components/unifiprotect/test_config_flow.py
+++ b/tests/components/unifiprotect/test_config_flow.py
@@ -226,9 +226,10 @@ async def test_form_reauth_auth(hass: HomeAssistant, nvr: NVR) -> None:
             result2["flow_id"],
             {
                 "username": "test-username",
-                "password": "test-password",
+                "password": "new-password",
             },
         )
+        await hass.async_block_till_done()
 
     assert result3["type"] == FlowResultType.ABORT
     assert result3["reason"] == "reauth_successful"
-- 
GitLab