From b6d26597c06de9e0ec4851d619bb78e1a2da82ee Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 11 Oct 2015 18:30:25 -0700 Subject: [PATCH] Automation - state platfor: Flag if user makes config error --- homeassistant/components/automation/state.py | 5 +++++ tests/components/automation/test_state.py | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/homeassistant/components/automation/state.py b/homeassistant/components/automation/state.py index 8baa0a01d46..5fc36300ed0 100644 --- a/homeassistant/components/automation/state.py +++ b/homeassistant/components/automation/state.py @@ -28,6 +28,11 @@ def trigger(hass, config, action): from_state = config.get(CONF_FROM, MATCH_ALL) to_state = config.get(CONF_TO) or config.get(CONF_STATE) or MATCH_ALL + if isinstance(from_state, bool) or isinstance(to_state, bool): + logging.getLogger(__name__).error( + 'Config error. Surround to/from values with quotes.') + return False + def state_automation_listener(entity, from_s, to_s): """ Listens for state changes and calls action. """ action() diff --git a/tests/components/automation/test_state.py b/tests/components/automation/test_state.py index a7c13e866c6..a31f694f8c0 100644 --- a/tests/components/automation/test_state.py +++ b/tests/components/automation/test_state.py @@ -8,6 +8,7 @@ import unittest import homeassistant.core as ha import homeassistant.components.automation as automation +import homeassistant.components.automation.state as state class TestAutomationState(unittest.TestCase): @@ -334,3 +335,19 @@ class TestAutomationState(unittest.TestCase): self.hass.pool.block_till_done() self.assertEqual(1, len(self.calls)) + + def test_if_fails_setup_if_to_boolean_value(self): + self.assertFalse(state.trigger( + self.hass, { + 'platform': 'state', + 'entity_id': 'test.entity', + 'to': True, + }, lambda x: x)) + + def test_if_fails_setup_if_from_boolean_value(self): + self.assertFalse(state.trigger( + self.hass, { + 'platform': 'state', + 'entity_id': 'test.entity', + 'from': True, + }, lambda x: x))