Continue on template error during yaml import for generic (#69440)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
fe8e193225
commit
c6bba19e05
1 changed files with 9 additions and 1 deletions
|
@ -136,7 +136,7 @@ async def async_test_still(hass, info) -> tuple[dict[str, str], str | None]:
|
|||
try:
|
||||
url = url.async_render(parse_result=False)
|
||||
except TemplateError as err:
|
||||
_LOGGER.error("Error parsing template %s: %s", url, err)
|
||||
_LOGGER.warning("Problem rendering template %s: %s", url, err)
|
||||
return {CONF_STILL_IMAGE_URL: "template_error"}, None
|
||||
verify_ssl = info.get(CONF_VERIFY_SSL)
|
||||
auth = generate_auth(info)
|
||||
|
@ -283,6 +283,14 @@ class GenericIPCamConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
if self.check_for_existing(import_config):
|
||||
return self.async_abort(reason="already_exists")
|
||||
errors, still_format = await async_test_still(self.hass, import_config)
|
||||
if errors.get(CONF_STILL_IMAGE_URL) == "template_error":
|
||||
_LOGGER.warning(
|
||||
"Could not render template, but it could be that "
|
||||
"referenced entities are still initialising. "
|
||||
"Continuing assuming that imported YAML template is valid"
|
||||
)
|
||||
errors.pop(CONF_STILL_IMAGE_URL)
|
||||
still_format = import_config.get(CONF_CONTENT_TYPE, "image/jpeg")
|
||||
errors = errors | await async_test_stream(self.hass, import_config)
|
||||
still_url = import_config.get(CONF_STILL_IMAGE_URL)
|
||||
stream_url = import_config.get(CONF_STREAM_SOURCE)
|
||||
|
|
Loading…
Add table
Reference in a new issue