Add optional "all" parameter for groups (#17179)

* Added optional mode parameter

* Cleanup

* Using boolean configuration

* Fix invalid syntax

* Added tests for all-parameter

* Grammar

* Lint

* Docstrings

* Better description
This commit is contained in:
Daniel Perna 2018-10-09 10:14:55 +02:00 committed by Paulus Schoutsen
parent 26cf5acd5b
commit 9d56730b8d
3 changed files with 59 additions and 8 deletions

View file

@ -108,6 +108,36 @@ class TestComponentsGroup(unittest.TestCase):
group_state = self.hass.states.get(test_group.entity_id)
self.assertEqual(STATE_ON, group_state.state)
def test_allgroup_stays_off_if_all_are_off_and_one_turns_on(self):
"""Group with all: true, stay off if one device turns on."""
self.hass.states.set('light.Bowl', STATE_OFF)
self.hass.states.set('light.Ceiling', STATE_OFF)
test_group = group.Group.create_group(
self.hass, 'init_group', ['light.Bowl', 'light.Ceiling'], False,
mode=True)
# Turn one on
self.hass.states.set('light.Ceiling', STATE_ON)
self.hass.block_till_done()
group_state = self.hass.states.get(test_group.entity_id)
self.assertEqual(STATE_OFF, group_state.state)
def test_allgroup_turn_on_if_last_turns_on(self):
"""Group with all: true, turn on if all devices are on."""
self.hass.states.set('light.Bowl', STATE_ON)
self.hass.states.set('light.Ceiling', STATE_OFF)
test_group = group.Group.create_group(
self.hass, 'init_group', ['light.Bowl', 'light.Ceiling'], False,
mode=True)
# Turn one on
self.hass.states.set('light.Ceiling', STATE_ON)
self.hass.block_till_done()
group_state = self.hass.states.get(test_group.entity_id)
self.assertEqual(STATE_ON, group_state.state)
def test_is_on(self):
"""Test is_on method."""
self.hass.states.set('light.Bowl', STATE_ON)