Add workaround for data entry flow show progress (#116704)

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
Erik Montnemery 2024-05-04 20:17:21 +02:00 committed by GitHub
parent ac12d2a463
commit 1e72e9e0b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -352,6 +352,18 @@ class FlowManager(abc.ABC, Generic[_FlowResultT, _HandlerT]):
) -> _FlowResultT: ) -> _FlowResultT:
"""Continue a data entry flow.""" """Continue a data entry flow."""
result: _FlowResultT | None = None result: _FlowResultT | None = None
# Workaround for flow handlers which have not been upgraded to pass a show
# progress task, needed because of the change to eager tasks in HA Core 2024.5,
# can be removed in HA Core 2024.8.
flow = self._progress.get(flow_id)
if flow and flow.deprecated_show_progress:
if (cur_step := flow.cur_step) and cur_step[
"type"
] == FlowResultType.SHOW_PROGRESS:
# Allow the progress task to finish before we call the flow handler
await asyncio.sleep(0)
while not result or result["type"] == FlowResultType.SHOW_PROGRESS_DONE: while not result or result["type"] == FlowResultType.SHOW_PROGRESS_DONE:
result = await self._async_configure(flow_id, user_input) result = await self._async_configure(flow_id, user_input)
flow = self._progress.get(flow_id) flow = self._progress.get(flow_id)