Optimize template 2 (#3521)

* Enforce compiling templates

* Refactor templates

* Add template validator to Logbook service

* Some more fixes

* Lint

* Allow easy skipping of rfxtrx tests

* Fix template bug in AND & OR conditions

* add entities extractor

Conflicts:
	tests/helpers/test_template.py

* fix unittest

* Convert template to be async

* Fix Farcy

* Lint fix

* Limit template updates to related entities

* Make template automation async
This commit is contained in:
Paulus Schoutsen 2016-09-27 21:29:55 -07:00 committed by GitHub
parent 6694b0470e
commit 00e298206e
52 changed files with 841 additions and 562 deletions

View file

@ -52,9 +52,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if value_template is None:
return lambda value: value
value_template = template.Template(value_template, hass)
def _render(value):
try:
return template.render(hass, value_template, {'value': value})
return value_template.render({'value': value})
except TemplateError:
_LOGGER.exception('Error parsing value')
return value