FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add LightEffect module for smart light strips by sdb9696 · Pull Request #918 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (8) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 5 additions & 4 deletions kasa/cli.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -911,11 +911,12 @@ async def effect(dev: Device, ctx, effect):
echo("Device does not support effects")
return
if effect is None:
raise click.BadArgumentUsage(
"Setting an effect requires a named built-in effect: "
+ f"{light_effect.effect_list}",
ctx,
echo(
f"Light effect: {light_effect.effect}\n"
+ f"Available Effects: {light_effect.effect_list}"
)
return light_effect.effect

if effect not in light_effect.effect_list:
raise click.BadArgumentUsage(
f"Effect must be one of: {light_effect.effect_list}", ctx
Expand Down
11 changes: 5 additions & 6 deletions kasa/iot/modules/lighteffect.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ def effect(self) -> str:
'id': '',
'name': ''}
"""
if (
(state := self.data.get("lighting_effect_state"))
and state.get("enable")
and (name := state.get("name"))
and name in EFFECT_NAMES_V1
):
eff = self.data["lighting_effect_state"]
name = eff["name"]
if eff["enable"]:
return name

return self.LIGHT_EFFECTS_OFF

@property
Expand Down Expand Up @@ -67,6 +65,7 @@ async def set_effect(
raise ValueError(f"The effect {effect} is not a built in effect.")
else:
effect_dict = EFFECT_MAPPING_V1[effect]

if brightness is not None:
effect_dict["brightness"] = brightness
if transition is not None:
Expand Down
Loading

Back | FazBrowse Home | New Git URL