Fix iot light effect brightness (#1092)

Fixes issue where the brightness of the `iot` light effect is set properly
on the light effect but read back incorrectly from the light.
This commit is contained in:
Steven B.
2024-07-31 15:58:48 +01:00
committed by GitHub
parent cb0077f634
commit 31ec27c1c8
8 changed files with 101 additions and 37 deletions

View File

@@ -30,26 +30,23 @@ async def test_light_strip_effect(dev: Device, mocker: MockerFixture):
call = mocker.spy(light_effect, "call")
light = dev.modules[Module.Light]
light_call = mocker.spy(light, "call")
assert feature.choices == light_effect.effect_list
assert feature.choices
for effect in chain(reversed(feature.choices), feature.choices):
if effect == LightEffect.LIGHT_EFFECTS_OFF:
off_effect = (
light_effect.effect
if light_effect.effect in light_effect._effect_mapping
else "Aurora"
)
await light_effect.set_effect(effect)
if effect == LightEffect.LIGHT_EFFECTS_OFF:
light_call.assert_called()
continue
# Start with the current effect data
params = light_effect.data["lighting_effect"]
enable = effect != LightEffect.LIGHT_EFFECTS_OFF
params["enable"] = enable
if enable:
params = light_effect._effect_mapping[effect]
params["enable"] = enable
params["brightness"] = brightness.brightness # use the existing brightness
if effect != LightEffect.LIGHT_EFFECTS_OFF:
params = {**light_effect._effect_mapping[effect]}
else:
params = {**light_effect._effect_mapping[off_effect]}
params["enable"] = 0
params["brightness"] = brightness.brightness # use the existing brightness
call.assert_called_with("set_lighting_effect", params)