Pre-compile templates (#3515)
* Pre-compile templates * Compile templates in numeric_state condition
This commit is contained in:
parent
b3d67a7ed9
commit
0c0feda834
15 changed files with 134 additions and 80 deletions
|
@ -12,7 +12,7 @@ from homeassistant.const import (
|
|||
CONF_VALUE_TEMPLATE, CONF_PLATFORM, CONF_ENTITY_ID,
|
||||
CONF_BELOW, CONF_ABOVE)
|
||||
from homeassistant.helpers.event import track_state_change
|
||||
from homeassistant.helpers import condition, config_validation as cv
|
||||
from homeassistant.helpers import condition, config_validation as cv, template
|
||||
|
||||
TRIGGER_SCHEMA = vol.All(vol.Schema({
|
||||
vol.Required(CONF_PLATFORM): 'numeric_state',
|
||||
|
@ -31,6 +31,8 @@ def trigger(hass, config, action):
|
|||
below = config.get(CONF_BELOW)
|
||||
above = config.get(CONF_ABOVE)
|
||||
value_template = config.get(CONF_VALUE_TEMPLATE)
|
||||
if value_template is not None:
|
||||
value_template = template.compile_template(hass, value_template)
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def state_automation_listener(entity, from_s, to_s):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue