|
3 | 3 | from __future__ import annotations
|
4 | 4 |
|
5 | 5 | from ...interfaces.lighteffect import LightEffect as LightEffectInterface
|
| 6 | +from ...module import Module |
6 | 7 | from ..effects import EFFECT_MAPPING_V1, EFFECT_NAMES_V1
|
7 | 8 | from ..iotmodule import IotModule
|
8 | 9 |
|
@@ -59,19 +60,24 @@ async def set_effect(
|
59 | 60 | :param int transition: The wanted transition time
|
60 | 61 | """
|
61 | 62 | if effect == self.LIGHT_EFFECTS_OFF:
|
62 |
| - effect_dict = dict(self.data["lighting_effect_state"]) |
63 |
| - effect_dict["enable"] = 0 |
| 63 | + light_module = self._device.modules[Module.Light] |
| 64 | + effect_off_state = light_module.state |
| 65 | + if brightness is not None: |
| 66 | + effect_off_state.brightness = brightness |
| 67 | + if transition is not None: |
| 68 | + effect_off_state.transition = transition |
| 69 | + await light_module.set_state(effect_off_state) |
64 | 70 | elif effect not in EFFECT_MAPPING_V1:
|
65 | 71 | raise ValueError(f"The effect {effect} is not a built in effect.")
|
66 | 72 | else:
|
67 | 73 | effect_dict = EFFECT_MAPPING_V1[effect]
|
68 | 74 |
|
69 |
| - if brightness is not None: |
70 |
| - effect_dict["brightness"] = brightness |
71 |
| - if transition is not None: |
72 |
| - effect_dict["transition"] = transition |
| 75 | + if brightness is not None: |
| 76 | + effect_dict["brightness"] = brightness |
| 77 | + if transition is not None: |
| 78 | + effect_dict["transition"] = transition |
73 | 79 |
|
74 |
| - await self.set_custom_effect(effect_dict) |
| 80 | + await self.set_custom_effect(effect_dict) |
75 | 81 |
|
76 | 82 | async def set_custom_effect(
|
77 | 83 | self,
|
|
0 commit comments