From fcbc399809e16dd9d79c1982c9ea16381cd4f88c Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen <amelchio@nogoto.net> Date: Fri, 1 Jun 2018 16:27:12 +0200 Subject: [PATCH] Disallow automation.trigger without entity_id (#14724) --- homeassistant/components/automation/__init__.py | 2 +- tests/components/automation/test_init.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index 2f510fd33d6..2a7a3887b34 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -98,7 +98,7 @@ SERVICE_SCHEMA = vol.Schema({ }) TRIGGER_SERVICE_SCHEMA = vol.Schema({ - vol.Optional(ATTR_ENTITY_ID): cv.entity_ids, + vol.Required(ATTR_ENTITY_ID): cv.entity_ids, vol.Optional(ATTR_VARIABLES, default={}): dict, }) diff --git a/tests/components/automation/test_init.py b/tests/components/automation/test_init.py index 7a8c097a730..33f1a7aa704 100644 --- a/tests/components/automation/test_init.py +++ b/tests/components/automation/test_init.py @@ -207,6 +207,7 @@ class TestAutomation(unittest.TestCase): """Test triggers.""" assert setup_component(self.hass, automation.DOMAIN, { automation.DOMAIN: { + 'alias': 'test', 'trigger': [ { 'platform': 'event', @@ -228,7 +229,9 @@ class TestAutomation(unittest.TestCase): self.hass.block_till_done() assert len(self.calls) == 0 - self.hass.services.call('automation', 'trigger', blocking=True) + self.hass.services.call('automation', 'trigger', + {'entity_id': 'automation.test'}, + blocking=True) self.hass.block_till_done() assert len(self.calls) == 1 -- GitLab