@@ -1905,8 +1905,8 @@ async def test_on_with_off_color(
1905
1905
new = AsyncMock (return_value = [sentinel .data , zcl_f .Status .SUCCESS ]),
1906
1906
)
1907
1907
@patch (
1908
- "zha.application.platforms.light.const.ASSUME_UPDATE_GROUP_FROM_CHILD_DELAY " ,
1909
- new = 0 ,
1908
+ "zigpy.zcl.clusters.general.LevelControl.request " ,
1909
+ new = AsyncMock ( return_value = [ sentinel . data , zcl_f . Status . SUCCESS ]) ,
1910
1910
)
1911
1911
@pytest .mark .looptime
1912
1912
async def test_group_member_assume_state (
@@ -1958,6 +1958,7 @@ async def test_group_member_assume_state(
1958
1958
# turn on via UI
1959
1959
await entity .async_turn_on ()
1960
1960
await zha_gateway .async_block_till_done ()
1961
+ await asyncio .sleep (1 ) # wait for assume debounce
1961
1962
1962
1963
# members also instantly assume STATE_ON
1963
1964
assert bool (device_1_light_entity .state ["on" ]) is True
@@ -1967,12 +1968,39 @@ async def test_group_member_assume_state(
1967
1968
# turn off via UI
1968
1969
await entity .async_turn_off ()
1969
1970
await zha_gateway .async_block_till_done ()
1971
+ await asyncio .sleep (1 )
1970
1972
1971
1973
# members also instantly assume STATE_OFF
1972
1974
assert bool (device_1_light_entity .state ["on" ]) is False
1973
1975
assert bool (device_2_light_entity .state ["on" ]) is False
1974
1976
assert bool (entity .state ["on" ]) is False
1975
1977
1978
+ # now test members with different state not being overridden
1979
+ # turn on light 1 to brightness 50
1980
+ await device_1_light_entity .async_turn_on (brightness = 50 )
1981
+ await zha_gateway .async_block_till_done ()
1982
+ assert bool (device_1_light_entity .state ["on" ]) is True
1983
+ assert device_1_light_entity .state ["brightness" ] == 50
1984
+
1985
+ # turn on light 2 to brightness 100
1986
+ await device_2_light_entity .async_turn_on (brightness = 100 )
1987
+ await zha_gateway .async_block_till_done ()
1988
+ assert bool (device_2_light_entity .state ["on" ]) is True
1989
+ assert device_2_light_entity .state ["brightness" ] == 100
1990
+
1991
+ await asyncio .sleep (1 ) # wait for assume debounce
1992
+
1993
+ # turn on group, but do not change brightness
1994
+ await entity .async_turn_on (brightness = None )
1995
+ await zha_gateway .async_block_till_done ()
1996
+ await asyncio .sleep (1 )
1997
+
1998
+ assert entity .state ["brightness" ] == 75 # average
1999
+
2000
+ # but members do not change unchanged state
2001
+ assert device_1_light_entity .state ["brightness" ] == 50
2002
+ assert device_2_light_entity .state ["brightness" ] == 100
2003
+
1976
2004
1977
2005
async def test_light_state_restoration (
1978
2006
device_light_3 , # pylint: disable=redefined-outer-name
0 commit comments