Fix automation failing to setup if no automations specified (#7647)
This commit is contained in:
parent
3d4b2436db
commit
e773133bcf
5 changed files with 11 additions and 16 deletions
|
@ -156,10 +156,7 @@ def async_setup(hass, config):
|
|||
component = EntityComponent(_LOGGER, DOMAIN, hass,
|
||||
group_name=GROUP_NAME_ALL_AUTOMATIONS)
|
||||
|
||||
success = yield from _async_process_config(hass, config, component)
|
||||
|
||||
if not success:
|
||||
return False
|
||||
yield from _async_process_config(hass, config, component)
|
||||
|
||||
descriptions = yield from hass.loop.run_in_executor(
|
||||
None, conf_util.load_yaml_config_file, os.path.join(
|
||||
|
@ -418,8 +415,6 @@ def _async_process_config(hass, config, component):
|
|||
if entities:
|
||||
yield from component.async_add_entities(entities)
|
||||
|
||||
return len(entities) > 0
|
||||
|
||||
|
||||
def _async_get_action(hass, config, name):
|
||||
"""Return an action based on a configuration."""
|
||||
|
|
|
@ -33,7 +33,7 @@ class TestAutomation(unittest.TestCase):
|
|||
def test_service_data_not_a_dict(self):
|
||||
"""Test service data not dict."""
|
||||
with assert_setup_component(0):
|
||||
assert not setup_component(self.hass, automation.DOMAIN, {
|
||||
assert setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'event',
|
||||
|
|
|
@ -245,7 +245,7 @@ class TestAutomationState(unittest.TestCase):
|
|||
def test_if_fails_setup_if_to_boolean_value(self):
|
||||
"""Test for setup failure for boolean to."""
|
||||
with assert_setup_component(0):
|
||||
assert not setup_component(self.hass, automation.DOMAIN, {
|
||||
assert setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'state',
|
||||
|
@ -260,7 +260,7 @@ class TestAutomationState(unittest.TestCase):
|
|||
def test_if_fails_setup_if_from_boolean_value(self):
|
||||
"""Test for setup failure for boolean from."""
|
||||
with assert_setup_component(0):
|
||||
assert not setup_component(self.hass, automation.DOMAIN, {
|
||||
assert setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'state',
|
||||
|
@ -275,7 +275,7 @@ class TestAutomationState(unittest.TestCase):
|
|||
def test_if_fails_setup_bad_for(self):
|
||||
"""Test for setup failure for bad for."""
|
||||
with assert_setup_component(0):
|
||||
assert not setup_component(self.hass, automation.DOMAIN, {
|
||||
assert setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'state',
|
||||
|
@ -293,7 +293,7 @@ class TestAutomationState(unittest.TestCase):
|
|||
def test_if_fails_setup_for_without_to(self):
|
||||
"""Test for setup failures for missing to."""
|
||||
with assert_setup_component(0):
|
||||
assert not setup_component(self.hass, automation.DOMAIN, {
|
||||
assert setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'state',
|
||||
|
@ -475,7 +475,7 @@ class TestAutomationState(unittest.TestCase):
|
|||
def test_if_fails_setup_for_without_time(self):
|
||||
"""Test for setup failure if no time is provided."""
|
||||
with assert_setup_component(0):
|
||||
assert not setup_component(self.hass, automation.DOMAIN, {
|
||||
assert setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'event',
|
||||
|
@ -493,7 +493,7 @@ class TestAutomationState(unittest.TestCase):
|
|||
def test_if_fails_setup_for_without_entity(self):
|
||||
"""Test for setup failure if no entity is provided."""
|
||||
with assert_setup_component(0):
|
||||
assert not setup_component(self.hass, automation.DOMAIN, {
|
||||
assert setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {'event_type': 'bla'},
|
||||
'condition': {
|
||||
|
|
|
@ -370,7 +370,7 @@ class TestAutomationTemplate(unittest.TestCase):
|
|||
def test_if_fires_on_change_with_bad_template(self):
|
||||
"""Test for firing on change with bad template."""
|
||||
with assert_setup_component(0):
|
||||
assert not setup_component(self.hass, automation.DOMAIN, {
|
||||
assert setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'template',
|
||||
|
|
|
@ -207,7 +207,7 @@ class TestAutomationTime(unittest.TestCase):
|
|||
def test_if_not_working_if_no_values_in_conf_provided(self):
|
||||
"""Test for failure if no configuration."""
|
||||
with assert_setup_component(0):
|
||||
assert not setup_component(self.hass, automation.DOMAIN, {
|
||||
assert setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'time',
|
||||
|
@ -230,7 +230,7 @@ class TestAutomationTime(unittest.TestCase):
|
|||
This should break the before rule.
|
||||
"""
|
||||
with assert_setup_component(0):
|
||||
assert not setup_component(self.hass, automation.DOMAIN, {
|
||||
assert setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
'platform': 'time',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue