mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add confirmation to Cast/Sonos/iOS config entries (#16769)
* Add confirmation to Cast/Sonos/iOS config entries * Remove redundant code
This commit is contained in:
committed by
Pascal Vizeli
parent
213171769d
commit
8b42d0c471
@@ -31,40 +31,39 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow):
|
||||
reason='single_instance_allowed'
|
||||
)
|
||||
|
||||
# Get current discovered entries.
|
||||
in_progress = self._async_in_progress()
|
||||
return await self.async_step_confirm()
|
||||
|
||||
has_devices = in_progress
|
||||
if not has_devices:
|
||||
has_devices = await self.hass.async_add_job(
|
||||
self._discovery_function, self.hass)
|
||||
|
||||
if not has_devices:
|
||||
return self.async_abort(
|
||||
reason='no_devices_found'
|
||||
async def async_step_confirm(self, user_input=None):
|
||||
"""Confirm setup."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(
|
||||
step_id='confirm',
|
||||
)
|
||||
|
||||
# Cancel the discovered one.
|
||||
for flow in in_progress:
|
||||
self.hass.config_entries.flow.async_abort(flow['flow_id'])
|
||||
if self.context and self.context.get('source') != \
|
||||
config_entries.SOURCE_DISCOVERY:
|
||||
# Get current discovered entries.
|
||||
in_progress = self._async_in_progress()
|
||||
|
||||
has_devices = in_progress
|
||||
if not has_devices:
|
||||
has_devices = await self.hass.async_add_job(
|
||||
self._discovery_function, self.hass)
|
||||
|
||||
if not has_devices:
|
||||
return self.async_abort(
|
||||
reason='no_devices_found'
|
||||
)
|
||||
|
||||
# Cancel the discovered one.
|
||||
for flow in in_progress:
|
||||
self.hass.config_entries.flow.async_abort(flow['flow_id'])
|
||||
|
||||
return self.async_create_entry(
|
||||
title=self._title,
|
||||
data={},
|
||||
)
|
||||
|
||||
async def async_step_confirm(self, user_input=None):
|
||||
"""Confirm setup."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(
|
||||
title=self._title,
|
||||
data={},
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id='confirm',
|
||||
)
|
||||
|
||||
async def async_step_discovery(self, discovery_info):
|
||||
"""Handle a flow initialized by discovery."""
|
||||
if self._async_in_progress() or self._async_current_entries():
|
||||
|
||||
Reference in New Issue
Block a user