Make lights supporting rgbw and rgbww accept colors (#49565)
* Allow lights supporting rgbw and rgbww accepting colors * Tweak, update tests
This commit is contained in:
parent
265fdea83b
commit
a5a3c98aff
2 changed files with 53 additions and 1 deletions
|
@ -1209,6 +1209,8 @@ async def test_light_service_call_color_conversion(hass):
|
|||
platform.ENTITIES.append(platform.MockLight("Test_xy", STATE_ON))
|
||||
platform.ENTITIES.append(platform.MockLight("Test_all", STATE_ON))
|
||||
platform.ENTITIES.append(platform.MockLight("Test_legacy", STATE_ON))
|
||||
platform.ENTITIES.append(platform.MockLight("Test_rgbw", STATE_ON))
|
||||
platform.ENTITIES.append(platform.MockLight("Test_rgbww", STATE_ON))
|
||||
|
||||
entity0 = platform.ENTITIES[0]
|
||||
entity0.supported_color_modes = {light.COLOR_MODE_HS}
|
||||
|
@ -1229,6 +1231,12 @@ async def test_light_service_call_color_conversion(hass):
|
|||
entity4 = platform.ENTITIES[4]
|
||||
entity4.supported_features = light.SUPPORT_COLOR
|
||||
|
||||
entity5 = platform.ENTITIES[5]
|
||||
entity5.supported_color_modes = {light.COLOR_MODE_RGBW}
|
||||
|
||||
entity6 = platform.ENTITIES[6]
|
||||
entity6.supported_color_modes = {light.COLOR_MODE_RGBWW}
|
||||
|
||||
assert await async_setup_component(hass, "light", {"light": {"platform": "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -1251,6 +1259,12 @@ async def test_light_service_call_color_conversion(hass):
|
|||
state = hass.states.get(entity4.entity_id)
|
||||
assert state.attributes["supported_color_modes"] == [light.COLOR_MODE_HS]
|
||||
|
||||
state = hass.states.get(entity5.entity_id)
|
||||
assert state.attributes["supported_color_modes"] == [light.COLOR_MODE_RGBW]
|
||||
|
||||
state = hass.states.get(entity6.entity_id)
|
||||
assert state.attributes["supported_color_modes"] == [light.COLOR_MODE_RGBWW]
|
||||
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
"turn_on",
|
||||
|
@ -1261,6 +1275,8 @@ async def test_light_service_call_color_conversion(hass):
|
|||
entity2.entity_id,
|
||||
entity3.entity_id,
|
||||
entity4.entity_id,
|
||||
entity5.entity_id,
|
||||
entity6.entity_id,
|
||||
],
|
||||
"brightness_pct": 100,
|
||||
"hs_color": (240, 100),
|
||||
|
@ -1277,6 +1293,10 @@ async def test_light_service_call_color_conversion(hass):
|
|||
assert data == {"brightness": 255, "hs_color": (240.0, 100.0)}
|
||||
_, data = entity4.last_call("turn_on")
|
||||
assert data == {"brightness": 255, "hs_color": (240.0, 100.0)}
|
||||
_, data = entity5.last_call("turn_on")
|
||||
assert data == {"brightness": 255, "rgbw_color": (0, 0, 255, 0)}
|
||||
_, data = entity6.last_call("turn_on")
|
||||
assert data == {"brightness": 255, "rgbww_color": (0, 0, 255, 0, 0)}
|
||||
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
|
@ -1288,6 +1308,8 @@ async def test_light_service_call_color_conversion(hass):
|
|||
entity2.entity_id,
|
||||
entity3.entity_id,
|
||||
entity4.entity_id,
|
||||
entity5.entity_id,
|
||||
entity6.entity_id,
|
||||
],
|
||||
"brightness_pct": 50,
|
||||
"rgb_color": (128, 0, 0),
|
||||
|
@ -1304,6 +1326,10 @@ async def test_light_service_call_color_conversion(hass):
|
|||
assert data == {"brightness": 128, "rgb_color": (128, 0, 0)}
|
||||
_, data = entity4.last_call("turn_on")
|
||||
assert data == {"brightness": 128, "hs_color": (0.0, 100.0)}
|
||||
_, data = entity5.last_call("turn_on")
|
||||
assert data == {"brightness": 128, "rgbw_color": (128, 0, 0, 0)}
|
||||
_, data = entity6.last_call("turn_on")
|
||||
assert data == {"brightness": 128, "rgbww_color": (128, 0, 0, 0, 0)}
|
||||
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
|
@ -1315,6 +1341,8 @@ async def test_light_service_call_color_conversion(hass):
|
|||
entity2.entity_id,
|
||||
entity3.entity_id,
|
||||
entity4.entity_id,
|
||||
entity5.entity_id,
|
||||
entity6.entity_id,
|
||||
],
|
||||
"brightness_pct": 50,
|
||||
"xy_color": (0.1, 0.8),
|
||||
|
@ -1331,6 +1359,10 @@ async def test_light_service_call_color_conversion(hass):
|
|||
assert data == {"brightness": 128, "xy_color": (0.1, 0.8)}
|
||||
_, data = entity4.last_call("turn_on")
|
||||
assert data == {"brightness": 128, "hs_color": (125.176, 100.0)}
|
||||
_, data = entity5.last_call("turn_on")
|
||||
assert data == {"brightness": 128, "rgbw_color": (0, 255, 22, 0)}
|
||||
_, data = entity6.last_call("turn_on")
|
||||
assert data == {"brightness": 128, "rgbww_color": (0, 255, 22, 0, 0)}
|
||||
|
||||
|
||||
async def test_light_state_color_conversion(hass):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue