Skip to content

Log invalid templates in script delays#13423

Merged
pvizeli merged 3 commits intohome-assistant:devfrom
amelchio:template-delay-exceptions
Mar 25, 2018
Merged

Log invalid templates in script delays#13423
pvizeli merged 3 commits intohome-assistant:devfrom
amelchio:template-delay-exceptions

Conversation

@amelchio
Copy link
Copy Markdown
Contributor

Description:

This PR makes the script delay: survive invalid templates. We used to log two tracebacks and break the script so it never completed.

Example entry for configuration.yaml (if applicable):

script:
  delay_template:
    sequence:
      - delay: '{{ unknown.attribute }}'

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@amelchio amelchio added this to the 0.66 milestone Mar 23, 2018
@amelchio amelchio requested a review from a team as a code owner March 23, 2018 23:14
except (TemplateError, vol.Invalid) as ex:
_LOGGER.error("Error rendering '%s' delay template: %s",
self.name, ex)
delay = timedelta(seconds=1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we should continue. We should abort instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

import logging
from itertools import islice
from typing import Optional, Sequence
from datetime import timedelta
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'datetime.timedelta' imported but unused

@pvizeli pvizeli merged commit 7166d53 into home-assistant:dev Mar 25, 2018
balloob pushed a commit that referenced this pull request Mar 26, 2018
* Log invalid templates in script delays

* Abort on error

* Remove unused import
@balloob balloob mentioned this pull request Mar 30, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants