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

Fix switching off light strip effects by sdb9696 · Pull Request #1024 · 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  (2) 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
8 changes: 5 additions & 3 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 @@ -105,9 +105,11 @@ async def set_effect(
"""
brightness_module = self._device.modules[Module.Brightness]
if effect == self.LIGHT_EFFECTS_OFF:
effect_dict = dict(self.data["lighting_effect"])
effect_dict["enable"] = 0
elif effect not in self._effect_mapping:
state = self._device.modules[Module.Light].state
await self._device.modules[Module.Light].set_state(state)
return
Comment thread
rytilahti marked this conversation as resolved.

if effect not in self._effect_mapping:
raise ValueError(f"The effect {effect} is not a built in effect.")
else:
effect_dict = self._effect_mapping[effect]
Expand Down
9 changes: 9 additions & 0 deletions kasa/tests/smart/modules/test_light_strip_effect.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 @@ -20,6 +20,7 @@
async def test_light_strip_effect(dev: Device, mocker: MockerFixture):
"""Test light strip effect."""
light_effect = dev.modules.get(Module.LightEffect)

assert isinstance(light_effect, LightStripEffect)

brightness = dev.modules[Module.Brightness]
Expand All @@ -28,11 +29,19 @@ async def test_light_strip_effect(dev: Device, mocker: MockerFixture):
assert feature.type == Feature.Type.Choice

call = mocker.spy(light_effect, "call")

light = dev.modules[Module.Light]
light_call = mocker.spy(light, "call")

assert feature.choices == light_effect.effect_list
assert feature.choices
for effect in chain(reversed(feature.choices), feature.choices):
await light_effect.set_effect(effect)

if effect == LightEffect.LIGHT_EFFECTS_OFF:
light_call.assert_called()
continue

# Start with the current effect data
params = light_effect.data["lighting_effect"]
enable = effect != LightEffect.LIGHT_EFFECTS_OFF
Expand Down

Back | FazBrowse Home | New Git URL