diff --git a/homeassistant/components/switch/template.py b/homeassistant/components/switch/template.py index 493b54c8b9c..ada27c21d0e 100644 --- a/homeassistant/components/switch/template.py +++ b/homeassistant/components/switch/template.py @@ -12,7 +12,7 @@ from homeassistant.const import ( from homeassistant.core import EVENT_STATE_CHANGED from homeassistant.exceptions import TemplateError from homeassistant.helpers.entity import generate_entity_id -from homeassistant.helpers.script import call_from_config +from homeassistant.helpers.script import Script from homeassistant.helpers import template from homeassistant.util import slugify @@ -86,8 +86,8 @@ class SwitchTemplate(SwitchDevice): hass=hass) self._name = friendly_name self._template = state_template - self._on_action = on_action - self._off_action = off_action + self._on_script = Script(hass, on_action) + self._off_script = Script(hass, off_action) self._state = False self.update() @@ -121,11 +121,11 @@ class SwitchTemplate(SwitchDevice): def turn_on(self, **kwargs): """Fire the on action.""" - call_from_config(self.hass, self._on_action, True) + self._on_script.run(True) def turn_off(self, **kwargs): """Fire the off action.""" - call_from_config(self.hass, self._off_action, True) + self._off_script.run(True) def update(self): """Update the state from the template."""