mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Clean up Onvif steps (#52254)
This commit is contained in:
parent
3f66709882
commit
8c37dc5613
@ -149,11 +149,15 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
return await self.async_step_configure()
|
return await self.async_step_configure()
|
||||||
|
|
||||||
async def async_step_configure(self, user_input=None, errors=None):
|
async def async_step_configure(self, user_input=None):
|
||||||
"""Device configuration."""
|
"""Device configuration."""
|
||||||
|
errors = {}
|
||||||
if user_input:
|
if user_input:
|
||||||
self.onvif_config = user_input
|
self.onvif_config = user_input
|
||||||
return await self.async_step_profiles()
|
try:
|
||||||
|
return await self.async_setup_profiles()
|
||||||
|
except Fault:
|
||||||
|
errors["base"] = "cannot_connect"
|
||||||
|
|
||||||
def conf(name, default=None):
|
def conf(name, default=None):
|
||||||
return self.onvif_config.get(name, default)
|
return self.onvif_config.get(name, default)
|
||||||
@ -176,10 +180,8 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_profiles(self, user_input=None):
|
async def async_setup_profiles(self):
|
||||||
"""Fetch ONVIF device profiles."""
|
"""Fetch ONVIF device profiles."""
|
||||||
errors = {}
|
|
||||||
|
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
"Fetching profiles from ONVIF device %s", pformat(self.onvif_config)
|
"Fetching profiles from ONVIF device %s", pformat(self.onvif_config)
|
||||||
)
|
)
|
||||||
@ -256,18 +258,12 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
return self.async_abort(reason="onvif_error")
|
return self.async_abort(reason="onvif_error")
|
||||||
|
|
||||||
except Fault:
|
|
||||||
errors["base"] = "cannot_connect"
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
await device.close()
|
await device.close()
|
||||||
|
|
||||||
return await self.async_step_configure(errors=errors)
|
|
||||||
|
|
||||||
async def async_step_import(self, user_input):
|
async def async_step_import(self, user_input):
|
||||||
"""Handle import."""
|
"""Handle import."""
|
||||||
self.onvif_config = user_input
|
return await self.async_step_configure(user_input)
|
||||||
return await self.async_step_profiles()
|
|
||||||
|
|
||||||
|
|
||||||
class OnvifOptionsFlowHandler(config_entries.OptionsFlow):
|
class OnvifOptionsFlowHandler(config_entries.OptionsFlow):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user