Skip to content

Commit

Permalink
Script delay now supports templating
Browse files Browse the repository at this point in the history
  • Loading branch information
Teagan42 committed Jul 19, 2016
1 parent efa42a9 commit ecf20c3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion homeassistant/helpers/script.py
Expand Up @@ -7,6 +7,7 @@
from homeassistant.const import EVENT_TIME_CHANGED, CONF_CONDITION
from homeassistant.helpers.event import track_point_in_utc_time
from homeassistant.helpers import service, condition
from homeassistant.helpers import template
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)
Expand All @@ -18,6 +19,7 @@
CONF_EVENT = "event"
CONF_EVENT_DATA = "event_data"
CONF_DELAY = "delay"
CONF_DELAY_TEMPLATE = 'delay_template'


def call_from_config(hass, config, variables=None):
Expand Down Expand Up @@ -68,9 +70,11 @@ def script_delay(now):
self._delay_listener = None
self.run(variables)

delay = action[CONF_DELAY] if CONF_DELAY in action else template.render(self.hass, action[CONF_DELAY_TEMPLATE], None)

self._delay_listener = track_point_in_utc_time(
self.hass, script_delay,
date_util.utcnow() + action[CONF_DELAY])
date_util.utcnow() + delay)
self._cur = cur + 1
if self._change_listener:
self._change_listener()
Expand Down

0 comments on commit ecf20c3

Please sign in to comment.