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

Handle unknown light effect names and only calculate effect list once by sdb9696 · Pull Request #973 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) 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
18 changes: 14 additions & 4 deletions kasa/smart/modules/lightstripeffect.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 @@ -2,16 +2,27 @@

from __future__ import annotations

from typing import TYPE_CHECKING

from ...interfaces.lighteffect import LightEffect as LightEffectInterface
from ..effects import EFFECT_MAPPING, EFFECT_NAMES
from ..smartmodule import SmartModule

if TYPE_CHECKING:
from ..smartdevice import SmartDevice


class LightStripEffect(SmartModule, LightEffectInterface):
"""Implementation of dynamic light effects."""

REQUIRED_COMPONENT = "light_strip_lighting_effect"

def __init__(self, device: SmartDevice, module: str):
super().__init__(device, module)
effect_list = [self.LIGHT_EFFECTS_OFF]
effect_list.extend(EFFECT_NAMES)
self._effect_list = effect_list

@property
def name(self) -> str:
"""Name of the module.
Expand All @@ -37,7 +48,8 @@ def effect(self) -> str:
"""
eff = self.data["lighting_effect"]
name = eff["name"]
if eff["enable"]:
# When devices are unpaired effect name is softAP which is not in our list
if eff["enable"] and name in self._effect_list:
return name
return self.LIGHT_EFFECTS_OFF

Expand All @@ -48,9 +60,7 @@ def effect_list(self) -> list[str]:
Example:
['Aurora', 'Bubbling Cauldron', ...]
"""
effect_list = [self.LIGHT_EFFECTS_OFF]
effect_list.extend(EFFECT_NAMES)
return effect_list
return self._effect_list

async def set_effect(
self,
Expand Down

Back | FazBrowse Home | New Git URL