1 """Support for Tikteck lights."""
3 from __future__
import annotations
9 import voluptuous
as vol
14 PLATFORM_SCHEMA
as LIGHT_PLATFORM_SCHEMA,
25 _LOGGER = logging.getLogger(__name__)
27 DEVICE_SCHEMA = vol.Schema(
28 {vol.Optional(CONF_NAME): cv.string, vol.Required(CONF_PASSWORD): cv.string}
31 PLATFORM_SCHEMA = LIGHT_PLATFORM_SCHEMA.extend(
32 {vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA}}
39 add_entities: AddEntitiesCallback,
40 discovery_info: DiscoveryInfoType |
None =
None,
42 """Set up the Tikteck platform."""
44 for address, device_config
in config[CONF_DEVICES].items():
46 device[
"name"] = device_config[CONF_NAME]
47 device[
"password"] = device_config[CONF_PASSWORD]
48 device[
"address"] = address
57 """Representation of a Tikteck light."""
59 _attr_assumed_state =
True
60 _attr_color_mode = ColorMode.HS
61 _attr_should_poll =
False
62 _attr_supported_color_modes = {ColorMode.HS}
63 hs_color: tuple[float, float]
67 """Initialize the light."""
69 address = device[
"address"]
76 self.
_bulb_bulb = tikteck.tikteck(address,
"Smart Light", device[
"password"])
77 if self.
_bulb_bulb.connect()
is False:
79 _LOGGER.error(
"Failed to connect to bulb %s, %s", address, self.
namename)
81 def set_state(self, red: int, green: int, blue: int, brightness: int) -> bool:
82 """Set the bulb state."""
86 """Turn the specified light on."""
89 hs_color = kwargs.get(ATTR_HS_COLOR)
90 brightness = kwargs.get(ATTR_BRIGHTNESS)
92 if hs_color
is not None:
94 if brightness
is not None:
97 rgb = color_util.color_hs_to_RGB(self.
hs_colorhs_color[0], self.
hs_colorhs_color[1])
103 """Turn the specified light off."""
int|None brightness(self)
tuple[float, float]|None hs_color(self)
def __init__(self, device)
None turn_off(self, **Any kwargs)
None turn_on(self, **Any kwargs)
bool set_state(self, int red, int green, int blue, int brightness)
None schedule_update_ha_state(self, bool force_refresh=False)
str|UndefinedType|None name(self)
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)