11from __future__ import annotations
22
33import logging
4- import time
54from abc import abstractmethod
65from typing import Any
76
87from ..helpers import create_background_task
98from ..models import SwitchBotAdvertisement
10- from .device import ColorMode , SwitchbotDevice
9+ from .device import SwitchbotDevice
1110
1211_LOGGER = logging .getLogger (__name__ )
1312
@@ -43,9 +42,10 @@ def brightness(self) -> int | None:
4342 return self ._get_adv_value ("brightness" ) or 0
4443
4544 @property
46- def color_mode (self ) -> ColorMode :
45+ @abstractmethod
46+ def color_mode (self ) -> Any :
4747 """Return the current color mode."""
48- return ColorMode ( self . _get_adv_value ( "color_mode" ) or 0 )
48+ raise NotImplementedError ( "Subclasses must implement color mode" )
4949
5050 @property
5151 def min_temp (self ) -> int :
@@ -57,10 +57,19 @@ def max_temp(self) -> int:
5757 """Return maximum color temp."""
5858 return 6500
5959
60+ @property
61+ def get_effect_list (self ) -> list [str ] | None :
62+ """Return the list of supported effects."""
63+ return None
64+
6065 def is_on (self ) -> bool | None :
6166 """Return bulb state from cache."""
6267 return self ._get_adv_value ("isOn" )
6368
69+ def get_effect (self ):
70+ """Return the current effect."""
71+ return self ._get_adv_value ("effect" )
72+
6473 @abstractmethod
6574 async def turn_on (self ) -> bool :
6675 """Turn device on."""
@@ -81,13 +90,18 @@ async def set_color_temp(self, brightness: int, color_temp: int) -> bool:
8190 async def set_rgb (self , brightness : int , r : int , g : int , b : int ) -> bool :
8291 """Set rgb."""
8392
84- def poll_needed (self , last_poll_time : float | None ) -> bool :
85- """Return if poll is needed."""
86- return False
87-
88- async def update (self ) -> None :
89- """Update device data."""
90- self ._last_full_update = time .monotonic ()
93+ async def _send_multiple_commands (self , keys : list [str ]) -> bool :
94+ """
95+ Send multiple commands to device.
96+
97+ Since we current have no way to tell which command the device
98+ needs we send both.
99+ """
100+ final_result = False
101+ for key in keys :
102+ result = await self ._send_command (key )
103+ final_result |= self ._check_command_result (result , 0 , {1 })
104+ return final_result
91105
92106
93107class SwitchbotSequenceBaseLight (SwitchbotBaseLight ):
0 commit comments