mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Pre-compile templates (#3515)
* Pre-compile templates * Compile templates in numeric_state condition
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user