Add automations and scripts to group.all_automations and group.all_scripts (#3664)

* Add automations to group.all_automations

* Add scripts to group.all_scripts
This commit is contained in:
Daniel Høyer Iversen 2016-10-05 06:20:48 +02:00 committed by Paulus Schoutsen
parent 0bf8bb62ad
commit d2d393feb5
4 changed files with 15 additions and 2 deletions

View file

@ -31,6 +31,8 @@ ENTITY_ID_FORMAT = DOMAIN + '.{}'
DEPENDENCIES = ['group']
GROUP_NAME_ALL_AUTOMATIONS = 'all automations'
CONF_ALIAS = 'alias'
CONF_HIDE_ENTITY = 'hide_entity'
@ -139,7 +141,8 @@ def reload(hass):
def setup(hass, config):
"""Setup the automation."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
component = EntityComponent(_LOGGER, DOMAIN, hass,
group_name=GROUP_NAME_ALL_AUTOMATIONS)
success = run_coroutine_threadsafe(
_async_process_config(hass, config, component), hass.loop).result()

View file

@ -23,6 +23,7 @@ from homeassistant.helpers.script import Script
DOMAIN = "script"
ENTITY_ID_FORMAT = DOMAIN + '.{}'
GROUP_NAME_ALL_SCRIPTS = 'all scripts'
DEPENDENCIES = ["group"]
CONF_SEQUENCE = "sequence"
@ -73,7 +74,8 @@ def toggle(hass, entity_id):
def setup(hass, config):
"""Load the scripts from the configuration."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
component = EntityComponent(_LOGGER, DOMAIN, hass,
group_name=GROUP_NAME_ALL_SCRIPTS)
def service_handler(service):
"""Execute a service call to script.<script name>."""

View file

@ -75,6 +75,10 @@ class TestAutomation(unittest.TestCase):
assert state is not None
assert state.attributes.get('last_triggered') == time
state = self.hass.states.get('group.all_automations')
assert state is not None
assert state.attributes.get('entity_id') == ('automation.hello',)
def test_service_specify_entity_id(self):
"""Test service data."""
assert setup_component(self.hass, automation.DOMAIN, {

View file

@ -82,6 +82,10 @@ class TestScriptComponent(unittest.TestCase):
self.hass.block_till_done()
self.assertEqual(0, len(events))
state = self.hass.states.get('group.all_scripts')
assert state is not None
assert state.attributes.get('entity_id') == (ENTITY_ID,)
def test_toggle_service(self):
"""Test the toggling of a service."""
event = 'test_event'