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 authored and GitHub committed 2016-09-27 21:29:55 -07:00
1 parent 6694b0470e
commit 00e298206e
52 files changed
+841 -562

No files matched your search

@@ -9,7 +9,7 @@ import subprocess
from homeassistant.components.rollershutter import RollershutterDevice
from homeassistant.const import CONF_VALUE_TEMPLATE
from homeassistant.helpers import template
from homeassistant.helpers.template import Template
_LOGGER = logging.getLogger(__name__)
@@ -20,6 +20,11 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
devices = []
for dev_name, properties in rollershutters.items():
value_template = properties.get(CONF_VALUE_TEMPLATE)
if value_template is not None:
value_template = Template(value_template, hass)
devices.append(
CommandRollershutter(
hass,
@@ -28,7 +33,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
properties.get('downcmd', 'true'),
properties.get('stopcmd', 'true'),
properties.get('statecmd', False),
properties.get(CONF_VALUE_TEMPLATE, '{{ value }}')))
value_template))
add_devices_callback(devices)
@@ -103,8 +108,8 @@ class CommandRollershutter(RollershutterDevice):
if self._command_state:
payload = str(self._query_state())
if self._value_template:
payload = template.render_with_possible_json_value(
self._hass, self._value_template, payload)
payload = self._value_template.render_with_possible_json_value(
payload)
self._state = int(payload)
def move_up(self, **kwargs):