8000 Add LightEffect module for smart light strips (#918) · python-kasa/python-kasa@133a839 · GitHub
[go: up one dir, main page]

Skip to content

Commit 133a839

Browse files
authored
Add LightEffect module for smart light strips (#918)
Implements the `light_strip_lighting_effect` components for `smart` devices. Uses a new list of effects captured from a L900 which are similar to the `iot` effects but include some additional properties and a few extra effects. Assumes that a device only implements `light_strip_lighting_effect` or `light_effect` but not both.
1 parent 67b5d7d commit 133a839

File tree

8 files changed

+572
-19
lines changed

8 files changed

+572
-19
lines changed

kasa/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -911,11 +911,12 @@ async def effect(dev: Device, ctx, effect):
911911
echo("Device does not support effects")
912912
return
913913
if effect is None:
914-
raise click.BadArgumentUsage(
915-
"Setting an effect requires a named built-in effect: "
916-
+ f"{light_effect.effect_list}",
917-
ctx,
914+
echo(
915+
f"Light effect: {light_effect.effect}\n"
916+
+ f"Available Effects: {light_effect.effect_list}"
918917
)
918+
return light_effect.effect
919+
919920
if effect not in light_effect.effect_list:
920921
raise click.BadArgumentUsage(
921922
f"Effect must be one of: {light_effect.effect_list}", ctx

kasa/iot/modules/lighteffect.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ def effect(self) -> str:
2121
'id': '',
2222
'name': ''}
2323
"""
24-
if (
25-
(state := self.data.get("lighting_effect_state"))
26-
and state.get("enable")
27-
and (name := state.get("name"))
28-
and name in EFFECT_NAMES_V1
29-
):
24+
eff = self.data["lighting_effect_state"]
25+
name = eff["name"]
26+
if eff["enable"]:
3027
return name
28+
3129
return self.LIGHT_EFFECTS_OFF
3230

3331
@property
@@ -67,6 +65,7 @@ async def set_effect(
6765
raise ValueError(f"The effect {effect} is not a built in effect.")
6866
else:
6967
effect_dict = EFFECT_MAPPING_V1[effect]
68+
7069
if brightness is not None:
7170
effect_dict["brightness"] = brightness
7271
if transition is not None:

0 commit comments

Comments
 (0)
0