Fix flux_led discovery with older models (#61413)

This commit is contained in:
J. Nick Koston 2021-12-09 21:29:27 -10:00 committed by GitHub
parent 8383da6a5e
commit 8d483e2206
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 71 additions and 24 deletions

View file

@ -80,7 +80,7 @@ async def test_light_unique_id(hass: HomeAssistant) -> None:
)
config_entry.add_to_hass(hass)
bulb = _mocked_bulb()
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -100,7 +100,7 @@ async def test_light_goes_unavailable_and_recovers(hass: HomeAssistant) -> None:
)
config_entry.add_to_hass(hass)
bulb = _mocked_bulb()
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -190,7 +190,7 @@ async def test_rgb_light(hass: HomeAssistant) -> None:
bulb.raw_state = bulb.raw_state._replace(model_num=0x33) # RGB only model
bulb.color_modes = {FLUX_COLOR_MODE_RGB}
bulb.color_mode = FLUX_COLOR_MODE_RGB
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(no_device=True), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -294,7 +294,7 @@ async def test_rgb_light_auto_on(hass: HomeAssistant) -> None:
bulb.raw_state = bulb.raw_state._replace(model_num=0x33) # RGB only model
bulb.color_modes = {FLUX_COLOR_MODE_RGB}
bulb.color_mode = FLUX_COLOR_MODE_RGB
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -407,7 +407,7 @@ async def test_rgb_cct_light(hass: HomeAssistant) -> None:
bulb.raw_state = bulb.raw_state._replace(model_num=0x35) # RGB & CCT model
bulb.color_modes = {FLUX_COLOR_MODE_RGB, FLUX_COLOR_MODE_CCT}
bulb.color_mode = FLUX_COLOR_MODE_RGB
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -526,7 +526,7 @@ async def test_rgbw_light(hass: HomeAssistant) -> None:
bulb = _mocked_bulb()
bulb.color_modes = {FLUX_COLOR_MODE_RGBW}
bulb.color_mode = FLUX_COLOR_MODE_RGBW
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -628,7 +628,7 @@ async def test_rgb_or_w_light(hass: HomeAssistant) -> None:
bulb = _mocked_bulb()
bulb.color_modes = FLUX_COLOR_MODES_RGB_W
bulb.color_mode = FLUX_COLOR_MODE_RGB
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -739,7 +739,7 @@ async def test_rgbcw_light(hass: HomeAssistant) -> None:
bulb.raw_state = bulb.raw_state._replace(warm_white=1, cool_white=2)
bulb.color_modes = {FLUX_COLOR_MODE_RGBWW, FLUX_COLOR_MODE_CCT}
bulb.color_mode = FLUX_COLOR_MODE_RGBWW
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -879,7 +879,7 @@ async def test_white_light(hass: HomeAssistant) -> None:
bulb.protocol = None
bulb.color_modes = {FLUX_COLOR_MODE_DIM}
bulb.color_mode = FLUX_COLOR_MODE_DIM
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -930,7 +930,7 @@ async def test_no_color_modes(hass: HomeAssistant) -> None:
bulb.protocol = None
bulb.color_modes = set()
bulb.color_mode = None
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -974,7 +974,7 @@ async def test_rgb_light_custom_effects(hass: HomeAssistant) -> None:
bulb = _mocked_bulb()
bulb.color_modes = {FLUX_COLOR_MODE_RGB}
bulb.color_mode = FLUX_COLOR_MODE_RGB
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -1056,7 +1056,7 @@ async def test_rgb_light_custom_effects_invalid_colors(
bulb = _mocked_bulb()
bulb.color_modes = {FLUX_COLOR_MODE_RGB}
bulb.color_mode = FLUX_COLOR_MODE_RGB
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -1085,7 +1085,7 @@ async def test_rgb_light_custom_effect_via_service(
bulb = _mocked_bulb()
bulb.color_modes = {FLUX_COLOR_MODE_RGB}
bulb.color_mode = FLUX_COLOR_MODE_RGB
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()
@ -1230,7 +1230,7 @@ async def test_addressable_light(hass: HomeAssistant) -> None:
bulb.raw_state = bulb.raw_state._replace(model_num=0x33) # RGB only model
bulb.color_modes = {FLUX_COLOR_MODE_ADDRESSABLE}
bulb.color_mode = FLUX_COLOR_MODE_ADDRESSABLE
with _patch_discovery(device=bulb), _patch_wifibulb(device=bulb):
with _patch_discovery(), _patch_wifibulb(device=bulb):
await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}})
await hass.async_block_till_done()