mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix script condition issue (Thanks @bart274) (#1972)
This commit is contained in:
parent
f2176e54ba
commit
2a972b7fe3
@ -118,7 +118,7 @@ class Script():
|
|||||||
def _check_condition(self, action, variables):
|
def _check_condition(self, action, variables):
|
||||||
"""Test if condition is matching."""
|
"""Test if condition is matching."""
|
||||||
self.last_action = action.get(CONF_ALIAS, action[CONF_CONDITION])
|
self.last_action = action.get(CONF_ALIAS, action[CONF_CONDITION])
|
||||||
check = condition.from_config(action)(self.hass, False)
|
check = condition.from_config(action)(self.hass, variables)
|
||||||
self._log("Test condition {}: {}".format(self.last_action, check))
|
self._log("Test condition {}: {}".format(self.last_action, check))
|
||||||
return check
|
return check
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
# Otherwise can't test just this file (import order issue)
|
||||||
|
import homeassistant.components # noqa
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
from homeassistant.helpers import script
|
from homeassistant.helpers import script
|
||||||
|
|
||||||
@ -233,9 +235,8 @@ class TestScriptHelper(unittest.TestCase):
|
|||||||
script_obj = script.Script(self.hass, [
|
script_obj = script.Script(self.hass, [
|
||||||
{'event': event},
|
{'event': event},
|
||||||
{
|
{
|
||||||
'condition': 'state',
|
'condition': 'template',
|
||||||
'entity_id': 'test.entity',
|
'value_template': '{{ states.test.entity.state == "hello" }}',
|
||||||
'state': 'hello',
|
|
||||||
},
|
},
|
||||||
{'event': event},
|
{'event': event},
|
||||||
])
|
])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user