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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion kasa/interfaces/lighteffect.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class LightEffect(Module, ABC):
"""Interface to represent a light effect module."""

LIGHT_EFFECTS_OFF = "Off"
LIGHT_EFFECTS_UNNAMED_CUSTOM = "Custom"

def _initialize_features(self) -> None:
"""Initialize features."""
Expand All @@ -77,7 +78,7 @@ def has_custom_effects(self) -> bool:
@property
@abstractmethod
def effect(self) -> str:
"""Return effect state or name."""
"""Return effect name."""

@property
@abstractmethod
Expand Down
13 changes: 2 additions & 11 deletions kasa/iot/modules/lighteffect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,11 @@ class LightEffect(IotModule, LightEffectInterface):

@property
def effect(self) -> str:
"""Return effect state.

Example:
{'brightness': 50,
'custom': 0,
'enable': 0,
'id': '',
'name': ''}
"""
"""Return effect name."""
eff = self.data["lighting_effect_state"]
name = eff["name"]
if eff["enable"]:
return name

return name or self.LIGHT_EFFECTS_UNNAMED_CUSTOM
return self.LIGHT_EFFECTS_OFF

@property
Expand Down
12 changes: 3 additions & 9 deletions kasa/smart/modules/lightstripeffect.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,14 @@

@property
def effect(self) -> str:
"""Return effect state.

Example:
{'brightness': 50,
'custom': 0,
'enable': 0,
'id': '',
'name': ''}
"""
"""Return effect name."""
eff = self.data["lighting_effect"]
name = eff["name"]
# 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
if eff["enable"] and eff["custom"]:
return name or self.LIGHT_EFFECTS_UNNAMED_CUSTOM

Check warning on line 47 in kasa/smart/modules/lightstripeffect.py

View check run for this annotation

Codecov / codecov/patch

kasa/smart/modules/lightstripeffect.py#L47

Added line #L47 was not covered by tests
return self.LIGHT_EFFECTS_OFF

@property
Expand Down
Loading