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
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 @@ def _post_update_hook(self):
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(
"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