|
@@ -1,13 +1,8 @@
|
|
|
from __future__ import annotations
|
|
|
|
|
|
-import asyncio
|
|
|
import logging
|
|
|
from typing import Any
|
|
|
|
|
|
-from switchbot.models import SwitchBotAdvertisement
|
|
|
-
|
|
|
-from .device import SwitchbotDevice, SwitchbotSequenceDevice
|
|
|
-
|
|
|
REQ_HEADER = "570f"
|
|
|
STRIP_COMMMAND_HEADER = "4901"
|
|
|
STRIP_REQUEST = f"{REQ_HEADER}4A01"
|
|
@@ -22,10 +17,11 @@ BRIGHTNESS_KEY = f"{STRIP_COMMAND}14"
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
+from .base_light import SwitchbotBaseLight
|
|
|
from .device import ColorMode
|
|
|
|
|
|
|
|
|
-class SwitchbotLightStrip(SwitchbotSequenceDevice):
|
|
|
+class SwitchbotLightStrip(SwitchbotBaseLight):
|
|
|
"""Representation of a Switchbot light strip."""
|
|
|
|
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
@@ -33,43 +29,11 @@ class SwitchbotLightStrip(SwitchbotSequenceDevice):
|
|
|
super().__init__(*args, **kwargs)
|
|
|
self._state: dict[str, Any] = {}
|
|
|
|
|
|
- @property
|
|
|
- def on(self) -> bool | None:
|
|
|
- """Return if bulb is on."""
|
|
|
- return self.is_on()
|
|
|
-
|
|
|
- @property
|
|
|
- def rgb(self) -> tuple[int, int, int] | None:
|
|
|
- """Return the current rgb value."""
|
|
|
- if "r" not in self._state or "g" not in self._state or "b" not in self._state:
|
|
|
- return None
|
|
|
- return self._state["r"], self._state["g"], self._state["b"]
|
|
|
-
|
|
|
- @property
|
|
|
- def brightness(self) -> int | None:
|
|
|
- """Return the current brightness value."""
|
|
|
- return self._get_adv_value("brightness") or 0
|
|
|
-
|
|
|
@property
|
|
|
def color_modes(self) -> set[ColorMode]:
|
|
|
"""Return the supported color modes."""
|
|
|
return {ColorMode.RGB}
|
|
|
|
|
|
- @property
|
|
|
- def min_temp(self) -> int:
|
|
|
- """Return minimum color temp."""
|
|
|
- return 0
|
|
|
-
|
|
|
- @property
|
|
|
- def max_temp(self) -> int:
|
|
|
- """Return maximum color temp."""
|
|
|
- return 0
|
|
|
-
|
|
|
- @property
|
|
|
- def color_mode(self) -> ColorMode:
|
|
|
- """Return the current color mode."""
|
|
|
- return ColorMode(self._get_adv_value("color_mode") or 0)
|
|
|
-
|
|
|
async def update(self) -> None:
|
|
|
"""Update state of device."""
|
|
|
result = await self._sendcommand(STRIP_REQUEST)
|
|
@@ -106,10 +70,6 @@ class SwitchbotLightStrip(SwitchbotSequenceDevice):
|
|
|
self._update_state(result)
|
|
|
return result[1] == 0x80
|
|
|
|
|
|
- def is_on(self) -> bool | None:
|
|
|
- """Return bulb state from cache."""
|
|
|
- return self._get_adv_value("isOn")
|
|
|
-
|
|
|
def _update_state(self, result: bytes) -> None:
|
|
|
"""Update device state."""
|
|
|
if len(result) < 10:
|