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:
parent
0bf8bb62ad
commit
d2d393feb5
4 changed files with 15 additions and 2 deletions
|
@ -31,6 +31,8 @@ ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
||||||
|
|
||||||
DEPENDENCIES = ['group']
|
DEPENDENCIES = ['group']
|
||||||
|
|
||||||
|
GROUP_NAME_ALL_AUTOMATIONS = 'all automations'
|
||||||
|
|
||||||
CONF_ALIAS = 'alias'
|
CONF_ALIAS = 'alias'
|
||||||
CONF_HIDE_ENTITY = 'hide_entity'
|
CONF_HIDE_ENTITY = 'hide_entity'
|
||||||
|
|
||||||
|
@ -139,7 +141,8 @@ def reload(hass):
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Setup the automation."""
|
"""Setup the automation."""
|
||||||
component = EntityComponent(_LOGGER, DOMAIN, hass)
|
component = EntityComponent(_LOGGER, DOMAIN, hass,
|
||||||
|
group_name=GROUP_NAME_ALL_AUTOMATIONS)
|
||||||
|
|
||||||
success = run_coroutine_threadsafe(
|
success = run_coroutine_threadsafe(
|
||||||
_async_process_config(hass, config, component), hass.loop).result()
|
_async_process_config(hass, config, component), hass.loop).result()
|
||||||
|
|
|
@ -23,6 +23,7 @@ from homeassistant.helpers.script import Script
|
||||||
|
|
||||||
DOMAIN = "script"
|
DOMAIN = "script"
|
||||||
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
||||||
|
GROUP_NAME_ALL_SCRIPTS = 'all scripts'
|
||||||
DEPENDENCIES = ["group"]
|
DEPENDENCIES = ["group"]
|
||||||
|
|
||||||
CONF_SEQUENCE = "sequence"
|
CONF_SEQUENCE = "sequence"
|
||||||
|
@ -73,7 +74,8 @@ def toggle(hass, entity_id):
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Load the scripts from the configuration."""
|
"""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):
|
def service_handler(service):
|
||||||
"""Execute a service call to script.<script name>."""
|
"""Execute a service call to script.<script name>."""
|
||||||
|
|
|
@ -75,6 +75,10 @@ class TestAutomation(unittest.TestCase):
|
||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.attributes.get('last_triggered') == time
|
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):
|
def test_service_specify_entity_id(self):
|
||||||
"""Test service data."""
|
"""Test service data."""
|
||||||
assert setup_component(self.hass, automation.DOMAIN, {
|
assert setup_component(self.hass, automation.DOMAIN, {
|
||||||
|
|
|
@ -82,6 +82,10 @@ class TestScriptComponent(unittest.TestCase):
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
self.assertEqual(0, len(events))
|
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):
|
def test_toggle_service(self):
|
||||||
"""Test the toggling of a service."""
|
"""Test the toggling of a service."""
|
||||||
event = 'test_event'
|
event = 'test_event'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue