Remove ConfigEntriesFlowManager.async_post_init (#142463)

Remove ConfigEntriesFlowManager.async_post_init
This commit is contained in:
Erik Montnemery 2025-04-07 13:28:09 +02:00 committed by GitHub
parent 2ed70ef241
commit 33fa8df73e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1367,12 +1367,12 @@ class ConfigEntriesFlowManager(
self._initialize_futures: defaultdict[str, set[asyncio.Future[None]]] = (
defaultdict(set)
)
self._discovery_debouncer = Debouncer[None](
self._discovery_event_debouncer = Debouncer[None](
hass,
_LOGGER,
cooldown=DISCOVERY_COOLDOWN,
immediate=True,
function=self._async_discovery,
function=self._async_fire_discovery_event,
background=True,
)
@ -1454,8 +1454,12 @@ class ConfigEntriesFlowManager(
if not self._pending_import_flows[handler]:
del self._pending_import_flows[handler]
if result["type"] != data_entry_flow.FlowResultType.ABORT:
await self.async_post_init(flow, result)
if (
result["type"] != data_entry_flow.FlowResultType.ABORT
and source in DISCOVERY_SOURCES
):
# Fire discovery event
await self._discovery_event_debouncer.async_call()
return result
@ -1497,7 +1501,7 @@ class ConfigEntriesFlowManager(
for future_list in self._initialize_futures.values():
for future in future_list:
future.set_result(None)
self._discovery_debouncer.async_shutdown()
self._discovery_event_debouncer.async_shutdown()
async def async_finish_flow(
self,
@ -1691,21 +1695,9 @@ class ConfigEntriesFlowManager(
flow.init_step = context["source"]
return flow
async def async_post_init(
self,
flow: data_entry_flow.FlowHandler[ConfigFlowContext, ConfigFlowResult],
result: ConfigFlowResult,
) -> None:
"""After a flow is initialised trigger new flow notifications."""
source = flow.context["source"]
# Create notification.
if source in DISCOVERY_SOURCES:
await self._discovery_debouncer.async_call()
@callback
def _async_discovery(self) -> None:
"""Handle discovery."""
def _async_fire_discovery_event(self) -> None:
"""Fire discovery event."""
# async_fire_internal is used here because this is only
# called from the Debouncer so we know the usage is safe
self.hass.bus.async_fire_internal(EVENT_FLOW_DISCOVERED)