mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-04-26 08:36:22 +00:00
Do not return empty string for custom light effect name (#1491)
This commit is contained in:
parent
09e73faca3
commit
82fbe1226e
@ -51,6 +51,7 @@ class LightEffect(Module, ABC):
|
|||||||
"""Interface to represent a light effect module."""
|
"""Interface to represent a light effect module."""
|
||||||
|
|
||||||
LIGHT_EFFECTS_OFF = "Off"
|
LIGHT_EFFECTS_OFF = "Off"
|
||||||
|
LIGHT_EFFECTS_UNNAMED_CUSTOM = "Custom"
|
||||||
|
|
||||||
def _initialize_features(self) -> None:
|
def _initialize_features(self) -> None:
|
||||||
"""Initialize features."""
|
"""Initialize features."""
|
||||||
@ -77,7 +78,7 @@ class LightEffect(Module, ABC):
|
|||||||
@property
|
@property
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def effect(self) -> str:
|
def effect(self) -> str:
|
||||||
"""Return effect state or name."""
|
"""Return effect name."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
@ -12,20 +12,11 @@ class LightEffect(IotModule, LightEffectInterface):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def effect(self) -> str:
|
def effect(self) -> str:
|
||||||
"""Return effect state.
|
"""Return effect name."""
|
||||||
|
|
||||||
Example:
|
|
||||||
{'brightness': 50,
|
|
||||||
'custom': 0,
|
|
||||||
'enable': 0,
|
|
||||||
'id': '',
|
|
||||||
'name': ''}
|
|
||||||
"""
|
|
||||||
eff = self.data["lighting_effect_state"]
|
eff = self.data["lighting_effect_state"]
|
||||||
name = eff["name"]
|
name = eff["name"]
|
||||||
if eff["enable"]:
|
if eff["enable"]:
|
||||||
return name
|
return name or self.LIGHT_EFFECTS_UNNAMED_CUSTOM
|
||||||
|
|
||||||
return self.LIGHT_EFFECTS_OFF
|
return self.LIGHT_EFFECTS_OFF
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -37,20 +37,14 @@ class LightStripEffect(SmartModule, SmartLightEffect):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def effect(self) -> str:
|
def effect(self) -> str:
|
||||||
"""Return effect state.
|
"""Return effect name."""
|
||||||
|
|
||||||
Example:
|
|
||||||
{'brightness': 50,
|
|
||||||
'custom': 0,
|
|
||||||
'enable': 0,
|
|
||||||
'id': '',
|
|
||||||
'name': ''}
|
|
||||||
"""
|
|
||||||
eff = self.data["lighting_effect"]
|
eff = self.data["lighting_effect"]
|
||||||
name = eff["name"]
|
name = eff["name"]
|
||||||
# When devices are unpaired effect name is softAP which is not in our list
|
# When devices are unpaired effect name is softAP which is not in our list
|
||||||
if eff["enable"] and name in self._effect_list:
|
if eff["enable"] and name in self._effect_list:
|
||||||
return name
|
return name
|
||||||
|
if eff["enable"] and eff["custom"]:
|
||||||
|
return name or self.LIGHT_EFFECTS_UNNAMED_CUSTOM
|
||||||
return self.LIGHT_EFFECTS_OFF
|
return self.LIGHT_EFFECTS_OFF
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user