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

@ -70,6 +70,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
sensor_names = config.get(CONF_SENSOR_NAMES)
interval = config.get(CONF_SCAN_INTERVAL)
if value_template is not None:
value_template.hass = hass
data = EmonCmsData(hass, url, apikey, interval)
data.update()
@ -123,9 +126,8 @@ class EmonCmsSensor(Entity):
self._elem = elem
if self._value_template is not None:
self._state = template.render_with_possible_json_value(
self._hass, self._value_template, elem["value"],
STATE_UNKNOWN)
self._state = self._value_template.render_with_possible_json_value(
elem["value"], STATE_UNKNOWN)
else:
self._state = round(float(elem["value"]), DECIMALS)
@ -177,9 +179,8 @@ class EmonCmsSensor(Entity):
self._elem = elem
if self._value_template is not None:
self._state = template.render_with_possible_json_value(
self._hass, self._value_template, elem["value"],
STATE_UNKNOWN)
self._state = self._value_template.render_with_possible_json_value(
elem["value"], STATE_UNKNOWN)
else:
self._state = round(float(elem["value"]), DECIMALS)