Clean up Light Groups (#12962)
* Clean up Light Groups * Fix tests * Remove light group from .coveragerc * async_schedule_update_ha_state called anyway
This commit is contained in:
1 parent
3ba19c52d5
commit
ca5f470956
3 files changed
+58
-58
No files matched your search
@@ -37,22 +37,22 @@ async def test_state_reporting(hass):
|
||||
hass.states.async_set('light.test1', 'on')
|
||||
hass.states.async_set('light.test2', 'unavailable')
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get('light.group_light').state == 'on'
|
||||
assert hass.states.get('light.light_group').state == 'on'
|
||||
|
||||
hass.states.async_set('light.test1', 'on')
|
||||
hass.states.async_set('light.test2', 'off')
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get('light.group_light').state == 'on'
|
||||
assert hass.states.get('light.light_group').state == 'on'
|
||||
|
||||
hass.states.async_set('light.test1', 'off')
|
||||
hass.states.async_set('light.test2', 'off')
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get('light.group_light').state == 'off'
|
||||
assert hass.states.get('light.light_group').state == 'off'
|
||||
|
||||
hass.states.async_set('light.test1', 'unavailable')
|
||||
hass.states.async_set('light.test2', 'unavailable')
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get('light.group_light').state == 'unavailable'
|
||||
assert hass.states.get('light.light_group').state == 'unavailable'
|
||||
|
||||
|
||||
async def test_brightness(hass):
|
||||
@@ -64,7 +64,7 @@ async def test_brightness(hass):
|
||||
hass.states.async_set('light.test1', 'on',
|
||||
{'brightness': 255, 'supported_features': 1})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.state == 'on'
|
||||
assert state.attributes['supported_features'] == 1
|
||||
assert state.attributes['brightness'] == 255
|
||||
@@ -72,14 +72,14 @@ async def test_brightness(hass):
|
||||
hass.states.async_set('light.test2', 'on',
|
||||
{'brightness': 100, 'supported_features': 1})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.state == 'on'
|
||||
assert state.attributes['brightness'] == 177
|
||||
|
||||
hass.states.async_set('light.test1', 'off',
|
||||
{'brightness': 255, 'supported_features': 1})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.state == 'on'
|
||||
assert state.attributes['supported_features'] == 1
|
||||
assert state.attributes['brightness'] == 100
|
||||
@@ -94,7 +94,7 @@ async def test_xy_color(hass):
|
||||
hass.states.async_set('light.test1', 'on',
|
||||
{'xy_color': (1.0, 1.0), 'supported_features': 64})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.state == 'on'
|
||||
assert state.attributes['supported_features'] == 64
|
||||
assert state.attributes['xy_color'] == (1.0, 1.0)
|
||||
@@ -102,14 +102,14 @@ async def test_xy_color(hass):
|
||||
hass.states.async_set('light.test2', 'on',
|
||||
{'xy_color': (0.5, 0.5), 'supported_features': 64})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.state == 'on'
|
||||
assert state.attributes['xy_color'] == (0.75, 0.75)
|
||||
|
||||
hass.states.async_set('light.test1', 'off',
|
||||
{'xy_color': (1.0, 1.0), 'supported_features': 64})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.state == 'on'
|
||||
assert state.attributes['xy_color'] == (0.5, 0.5)
|
||||
|
||||
@@ -123,7 +123,7 @@ async def test_rgb_color(hass):
|
||||
hass.states.async_set('light.test1', 'on',
|
||||
{'rgb_color': (255, 0, 0), 'supported_features': 16})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.state == 'on'
|
||||
assert state.attributes['supported_features'] == 16
|
||||
assert state.attributes['rgb_color'] == (255, 0, 0)
|
||||
@@ -132,13 +132,13 @@ async def test_rgb_color(hass):
|
||||
{'rgb_color': (255, 255, 255),
|
||||
'supported_features': 16})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['rgb_color'] == (255, 127, 127)
|
||||
|
||||
hass.states.async_set('light.test1', 'off',
|
||||
{'rgb_color': (255, 0, 0), 'supported_features': 16})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['rgb_color'] == (255, 255, 255)
|
||||
|
||||
|
||||
@@ -151,19 +151,19 @@ async def test_white_value(hass):
|
||||
hass.states.async_set('light.test1', 'on',
|
||||
{'white_value': 255, 'supported_features': 128})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['white_value'] == 255
|
||||
|
||||
hass.states.async_set('light.test2', 'on',
|
||||
{'white_value': 100, 'supported_features': 128})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['white_value'] == 177
|
||||
|
||||
hass.states.async_set('light.test1', 'off',
|
||||
{'white_value': 255, 'supported_features': 128})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['white_value'] == 100
|
||||
|
||||
|
||||
@@ -176,19 +176,19 @@ async def test_color_temp(hass):
|
||||
hass.states.async_set('light.test1', 'on',
|
||||
{'color_temp': 2, 'supported_features': 2})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['color_temp'] == 2
|
||||
|
||||
hass.states.async_set('light.test2', 'on',
|
||||
{'color_temp': 1000, 'supported_features': 2})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['color_temp'] == 501
|
||||
|
||||
hass.states.async_set('light.test1', 'off',
|
||||
{'color_temp': 2, 'supported_features': 2})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['color_temp'] == 1000
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ async def test_min_max_mireds(hass):
|
||||
{'min_mireds': 2, 'max_mireds': 5,
|
||||
'supported_features': 2})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['min_mireds'] == 2
|
||||
assert state.attributes['max_mireds'] == 5
|
||||
|
||||
@@ -210,7 +210,7 @@ async def test_min_max_mireds(hass):
|
||||
{'min_mireds': 7, 'max_mireds': 1234567890,
|
||||
'supported_features': 2})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['min_mireds'] == 2
|
||||
assert state.attributes['max_mireds'] == 1234567890
|
||||
|
||||
@@ -218,7 +218,7 @@ async def test_min_max_mireds(hass):
|
||||
{'min_mireds': 1, 'max_mireds': 2,
|
||||
'supported_features': 2})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['min_mireds'] == 1
|
||||
assert state.attributes['max_mireds'] == 1234567890
|
||||
|
||||
@@ -232,21 +232,21 @@ async def test_effect_list(hass):
|
||||
hass.states.async_set('light.test1', 'on',
|
||||
{'effect_list': ['None', 'Random', 'Colorloop']})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert set(state.attributes['effect_list']) == {
|
||||
'None', 'Random', 'Colorloop'}
|
||||
|
||||
hass.states.async_set('light.test2', 'on',
|
||||
{'effect_list': ['None', 'Random', 'Rainbow']})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert set(state.attributes['effect_list']) == {
|
||||
'None', 'Random', 'Colorloop', 'Rainbow'}
|
||||
|
||||
hass.states.async_set('light.test1', 'off',
|
||||
{'effect_list': ['None', 'Colorloop', 'Seven']})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert set(state.attributes['effect_list']) == {
|
||||
'None', 'Random', 'Colorloop', 'Seven', 'Rainbow'}
|
||||
|
||||
@@ -261,19 +261,19 @@ async def test_effect(hass):
|
||||
hass.states.async_set('light.test1', 'on',
|
||||
{'effect': 'None', 'supported_features': 2})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['effect'] == 'None'
|
||||
|
||||
hass.states.async_set('light.test2', 'on',
|
||||
{'effect': 'None', 'supported_features': 2})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['effect'] == 'None'
|
||||
|
||||
hass.states.async_set('light.test3', 'on',
|
||||
{'effect': 'Random', 'supported_features': 2})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['effect'] == 'None'
|
||||
|
||||
hass.states.async_set('light.test1', 'off',
|
||||
@@ -281,7 +281,7 @@ async def test_effect(hass):
|
||||
hass.states.async_set('light.test2', 'off',
|
||||
{'effect': 'None', 'supported_features': 2})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['effect'] == 'Random'
|
||||
|
||||
|
||||
@@ -294,25 +294,25 @@ async def test_supported_features(hass):
|
||||
hass.states.async_set('light.test1', 'on',
|
||||
{'supported_features': 0})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['supported_features'] == 0
|
||||
|
||||
hass.states.async_set('light.test2', 'on',
|
||||
{'supported_features': 2})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['supported_features'] == 2
|
||||
|
||||
hass.states.async_set('light.test1', 'off',
|
||||
{'supported_features': 41})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['supported_features'] == 43
|
||||
|
||||
hass.states.async_set('light.test2', 'off',
|
||||
{'supported_features': 256})
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('light.group_light')
|
||||
state = hass.states.get('light.light_group')
|
||||
assert state.attributes['supported_features'] == 41
|
||||
|
||||
|
||||
@@ -326,29 +326,29 @@ async def test_service_calls(hass):
|
||||
]})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get('light.group_light').state == 'on'
|
||||
light.async_toggle(hass, 'light.group_light')
|
||||
assert hass.states.get('light.light_group').state == 'on'
|
||||
light.async_toggle(hass, 'light.light_group')
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get('light.bed_light').state == 'off'
|
||||
assert hass.states.get('light.ceiling_lights').state == 'off'
|
||||
assert hass.states.get('light.kitchen_lights').state == 'off'
|
||||
|
||||
light.async_turn_on(hass, 'light.group_light')
|
||||
light.async_turn_on(hass, 'light.light_group')
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get('light.bed_light').state == 'on'
|
||||
assert hass.states.get('light.ceiling_lights').state == 'on'
|
||||
assert hass.states.get('light.kitchen_lights').state == 'on'
|
||||
|
||||
light.async_turn_off(hass, 'light.group_light')
|
||||
light.async_turn_off(hass, 'light.light_group')
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get('light.bed_light').state == 'off'
|
||||
assert hass.states.get('light.ceiling_lights').state == 'off'
|
||||
assert hass.states.get('light.kitchen_lights').state == 'off'
|
||||
|
||||
light.async_turn_on(hass, 'light.group_light', brightness=128,
|
||||
light.async_turn_on(hass, 'light.light_group', brightness=128,
|
||||
effect='Random', rgb_color=(42, 255, 255))
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
Reference in new issue
Block a user