Add brightness to lightstrip's set_effect (#415)

* Add brightness parameter to lightstrip's set_effect

* Use None as default as effects have different default brightnesses
This commit is contained in:
Teemu R
2023-01-21 00:25:59 +01:00
committed by GitHub
parent bfafbf9512
commit 6e7a588d40
2 changed files with 23 additions and 3 deletions

View File

@@ -89,16 +89,19 @@ class SmartLightStrip(SmartBulb):
@requires_update
async def set_effect(
self,
effect: str,
self, effect: str, *, brightness: Optional[int] = None
) -> None:
"""Set an effect on the device.
:param str effect: The effect to set
:param int brightness: The wanted brightness
"""
if effect not in EFFECT_MAPPING_V1:
raise SmartDeviceException(f"The effect {effect} is not a built in effect.")
await self.set_custom_effect(EFFECT_MAPPING_V1[effect])
effect_dict = EFFECT_MAPPING_V1[effect]
if brightness is not None:
effect_dict["brightness"] = brightness
await self.set_custom_effect(effect_dict)
@requires_update
async def set_custom_effect(