From cf69da40f3f0cd2ae65e611b70faa72235003408 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 26 Apr 2023 03:23:18 -0500 Subject: [PATCH] Only check support_entry_unload/support_remove_from_device once (#92041) --- homeassistant/components/config/config_entries.py | 4 ++-- homeassistant/config_entries.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/config/config_entries.py b/homeassistant/components/config/config_entries.py index 88715ab876e..c6fd4003156 100644 --- a/homeassistant/components/config/config_entries.py +++ b/homeassistant/components/config/config_entries.py @@ -535,8 +535,8 @@ def entry_json(entry: config_entries.ConfigEntry) -> dict: "source": entry.source, "state": entry.state.value, "supports_options": supports_options, - "supports_remove_device": entry.supports_remove_device, - "supports_unload": entry.supports_unload, + "supports_remove_device": entry.supports_remove_device or False, + "supports_unload": entry.supports_unload or False, "pref_disable_new_entities": entry.pref_disable_new_entities, "pref_disable_polling": entry.pref_disable_polling, "disabled_by": entry.disabled_by, diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 574fdda0252..adbb2f80f64 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -294,10 +294,10 @@ class ConfigEntry: self.disabled_by = disabled_by # Supports unload - self.supports_unload = False + self.supports_unload: bool | None = None # Supports remove device - self.supports_remove_device = False + self.supports_remove_device: bool | None = None # Listeners to call on update self.update_listeners: list[ @@ -340,10 +340,12 @@ class ConfigEntry: if self.domain == integration.domain: self.async_set_state(hass, ConfigEntryState.SETUP_IN_PROGRESS, None) - self.supports_unload = await support_entry_unload(hass, self.domain) - self.supports_remove_device = await support_remove_from_device( - hass, self.domain - ) + if self.supports_unload is None: + self.supports_unload = await support_entry_unload(hass, self.domain) + if self.supports_remove_device is None: + self.supports_remove_device = await support_remove_from_device( + hass, self.domain + ) try: component = integration.get_component()