Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log invalid templates in script delays #13423

Merged
merged 3 commits into from
Mar 25, 2018

Conversation

amelchio
Copy link
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
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
Contributor Author

Choose a reason for hiding this comment

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

Okay.

@@ -3,6 +3,7 @@
import logging
from itertools import islice
from typing import Optional, Sequence
from datetime import timedelta

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