8000 Fix light preset module when list contains lighting effects by sdb9696 · Pull Request #1048 · python-kasa/python-kasa · GitHub
[go: up one dir, main page]

Skip to content

Fix light preset module when list contains lighting effects #1048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2024
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
11 changes: 11 additions & 0 deletions kasa/smart/modules/lightpreset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import logging
from collections.abc import Sequence
from dataclasses import asdict
from typing import TYPE_CHECKING
Expand All @@ -13,6 +14,8 @@
if TYPE_CHECKING:
from ..smartdevice import SmartDevice

_LOGGER = logging.getLogger(__name__)


class LightPreset(SmartModule, LightPresetInterface):
"""Implementation of light presets."""
Expand All @@ -38,6 +41,14 @@
state_key = "states" if not self._state_in_sysinfo else self.SYS_INFO_STATE_KEY
if preset_states := self.data.get(state_key):
for preset_state in preset_states:
if "brightness" not in preset_state:
# Some devices can store effects as a preset. These will be ignored
# and handled in the effects module
if "lighting_effect" not in preset_state:
_LOGGER.info(

Check warning on line 48 in kasa/smart/modules/lightpreset.py

View check run for this annotation

Codecov / codecov/patch

kasa/smart/modules/lightpreset.py#L48

Added line #L48 was not covered by tests
"Unexpected keys %s in preset", list(preset_state.keys())
)
continue
color_temp = preset_state.get("color_temp")
hue = preset_state.get("hue")
saturation = preset_state.get("saturation")
Expand Down
Loading
Loading
0