From b3464c508730d43f14bfd07b24ea5853d5424283 Mon Sep 17 00:00:00 2001
From: jjlawren <jjlawren@users.noreply.github.com>
Date: Thu, 1 Oct 2020 14:38:57 -0500
Subject: [PATCH] Remove unnecessary instance attribute in Plex reauth config
 flow (#41000)

* Avoid unnecessary instance attribute

* Don't need to enrich existing entry data
---
 homeassistant/components/plex/__init__.py    | 2 +-
 homeassistant/components/plex/config_flow.py | 5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/homeassistant/components/plex/__init__.py b/homeassistant/components/plex/__init__.py
index 95fb6e4f09f..3682f362700 100644
--- a/homeassistant/components/plex/__init__.py
+++ b/homeassistant/components/plex/__init__.py
@@ -114,7 +114,7 @@ async def async_setup_entry(hass, entry):
             hass.config_entries.flow.async_init(
                 PLEX_DOMAIN,
                 context={CONF_SOURCE: SOURCE_REAUTH},
-                data={**entry.data, "config_entry_id": entry.entry_id},
+                data=entry.data,
             )
         )
         _LOGGER.error(
diff --git a/homeassistant/components/plex/config_flow.py b/homeassistant/components/plex/config_flow.py
index b2bf856402e..bdbdc9c6cc9 100644
--- a/homeassistant/components/plex/config_flow.py
+++ b/homeassistant/components/plex/config_flow.py
@@ -96,7 +96,6 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
         self.token = None
         self.client_id = None
         self._manual = False
-        self._entry_id = None
 
     async def async_step_user(
         self, user_input=None, errors=None
@@ -230,12 +229,11 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
             PLEX_SERVER_CONFIG: entry_config,
         }
 
-        await self.async_set_unique_id(server_id)
+        entry = await self.async_set_unique_id(server_id)
         if (
             self.context[CONF_SOURCE]  # pylint: disable=no-member
             == config_entries.SOURCE_REAUTH
         ):
-            entry = self.hass.config_entries.async_get_entry(self._entry_id)
             self.hass.config_entries.async_update_entry(entry, data=data)
             _LOGGER.debug("Updated config entry for %s", plex_server.friendly_name)
             await self.hass.config_entries.async_reload(entry.entry_id)
@@ -329,7 +327,6 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
     async def async_step_reauth(self, data):
         """Handle a reauthorization flow request."""
         self.current_login = dict(data)
-        self._entry_id = self.current_login.pop("config_entry_id")
         return await self.async_step_user()
 
 
-- 
GitLab