1 """Support for Unifi Led lights."""
3 from __future__
import annotations
8 from unifiled
import unifiled
9 import voluptuous
as vol
13 PLATFORM_SCHEMA
as LIGHT_PLATFORM_SCHEMA,
23 _LOGGER = logging.getLogger(__name__)
26 PLATFORM_SCHEMA = LIGHT_PLATFORM_SCHEMA.extend(
28 vol.Required(CONF_HOST): cv.string,
29 vol.Required(CONF_USERNAME): cv.string,
30 vol.Required(CONF_PASSWORD): cv.string,
31 vol.Optional(CONF_PORT, default=20443): vol.All(cv.port, cv.string),
39 add_entities: AddEntitiesCallback,
40 discovery_info: DiscoveryInfoType |
None =
None,
42 """Set up the Unifi LED platform."""
46 host = config[CONF_HOST]
47 port = config[CONF_PORT]
48 username = config[CONF_USERNAME]
49 password = config[CONF_PASSWORD]
51 api = unifiled(host, port, username=username, password=password)
54 if not api.getloginstate():
55 _LOGGER.error(
"Could not connect to unifiled controller")
62 """Representation of an unifiled Light."""
64 _attr_color_mode = ColorMode.BRIGHTNESS
65 _attr_supported_color_modes = {ColorMode.BRIGHTNESS}
67 def __init__(self, light: dict[str, Any], api: unifiled) ->
None:
68 """Init Unifi LED Light."""
80 """Instruct the light to turn on."""
81 self.
_api_api.setdevicebrightness(
83 str(self.
_api_api.convertfrom255to100(kwargs.get(ATTR_BRIGHTNESS, 255))),
88 """Instruct the light to turn off."""
92 """Update the light states."""
None turn_on(self, **Any kwargs)
None __init__(self, dict[str, Any] light, unifiled api)
None turn_off(self, **Any kwargs)
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)