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:
1 parent
26cf5acd5b
commit
9d56730b8d
3 files changed
+59
-8
No files matched your search
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user