Home Assistant Unofficial Reference 2024.12.1
light.py
Go to the documentation of this file.
1 """Support for KNX/IP lights."""
2 
3 from __future__ import annotations
4 
5 from typing import Any, cast
6 
7 from propcache import cached_property
8 from xknx import XKNX
9 from xknx.devices.light import ColorTemperatureType, Light as XknxLight, XYYColor
10 
11 from homeassistant import config_entries
13  ATTR_BRIGHTNESS,
14  ATTR_COLOR_TEMP_KELVIN,
15  ATTR_HS_COLOR,
16  ATTR_RGB_COLOR,
17  ATTR_RGBW_COLOR,
18  ATTR_XY_COLOR,
19  ColorMode,
20  LightEntity,
21 )
22 from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME, Platform
23 from homeassistant.core import HomeAssistant
25  AddEntitiesCallback,
26  async_get_current_platform,
27 )
28 from homeassistant.helpers.typing import ConfigType
29 import homeassistant.util.color as color_util
30 
31 from . import KNXModule
32 from .const import CONF_SYNC_STATE, DOMAIN, KNX_ADDRESS, KNX_MODULE_KEY, ColorTempModes
33 from .entity import KnxUiEntity, KnxUiEntityPlatformController, KnxYamlEntity
34 from .schema import LightSchema
35 from .storage.const import (
36  CONF_COLOR_TEMP_MAX,
37  CONF_COLOR_TEMP_MIN,
38  CONF_DPT,
39  CONF_ENTITY,
40  CONF_GA_BLUE_BRIGHTNESS,
41  CONF_GA_BLUE_SWITCH,
42  CONF_GA_BRIGHTNESS,
43  CONF_GA_COLOR,
44  CONF_GA_COLOR_TEMP,
45  CONF_GA_GREEN_BRIGHTNESS,
46  CONF_GA_GREEN_SWITCH,
47  CONF_GA_HUE,
48  CONF_GA_PASSIVE,
49  CONF_GA_RED_BRIGHTNESS,
50  CONF_GA_RED_SWITCH,
51  CONF_GA_SATURATION,
52  CONF_GA_STATE,
53  CONF_GA_SWITCH,
54  CONF_GA_WHITE_BRIGHTNESS,
55  CONF_GA_WHITE_SWITCH,
56  CONF_GA_WRITE,
57 )
58 from .storage.entity_store_schema import LightColorMode
59 
60 
62  hass: HomeAssistant,
63  config_entry: config_entries.ConfigEntry,
64  async_add_entities: AddEntitiesCallback,
65 ) -> None:
66  """Set up light(s) for KNX platform."""
67  knx_module = hass.data[KNX_MODULE_KEY]
68  platform = async_get_current_platform()
69  knx_module.config_store.add_platform(
70  platform=Platform.LIGHT,
72  knx_module=knx_module,
73  entity_platform=platform,
74  entity_class=KnxUiLight,
75  ),
76  )
77 
78  entities: list[KnxYamlEntity | KnxUiEntity] = []
79  if yaml_platform_config := knx_module.config_yaml.get(Platform.LIGHT):
80  entities.extend(
81  KnxYamlLight(knx_module, entity_config)
82  for entity_config in yaml_platform_config
83  )
84  if ui_config := knx_module.config_store.data["entities"].get(Platform.LIGHT):
85  entities.extend(
86  KnxUiLight(knx_module, unique_id, config)
87  for unique_id, config in ui_config.items()
88  )
89  if entities:
90  async_add_entities(entities)
91 
92 
93 def _create_yaml_light(xknx: XKNX, config: ConfigType) -> XknxLight:
94  """Return a KNX Light device to be used within XKNX."""
95 
96  def individual_color_addresses(color: str, feature: str) -> Any | None:
97  """Load individual color address list from configuration structure."""
98  if (
99  LightSchema.CONF_INDIVIDUAL_COLORS not in config
100  or color not in config[LightSchema.CONF_INDIVIDUAL_COLORS]
101  ):
102  return None
103  return config[LightSchema.CONF_INDIVIDUAL_COLORS][color].get(feature)
104 
105  group_address_tunable_white = None
106  group_address_tunable_white_state = None
107  group_address_color_temp = None
108  group_address_color_temp_state = None
109  color_temperature_type = ColorTemperatureType.UINT_2_BYTE
110  if config[LightSchema.CONF_COLOR_TEMP_MODE] == ColorTempModes.RELATIVE:
111  group_address_tunable_white = config.get(LightSchema.CONF_COLOR_TEMP_ADDRESS)
112  group_address_tunable_white_state = config.get(
113  LightSchema.CONF_COLOR_TEMP_STATE_ADDRESS
114  )
115  else:
116  # absolute uint or float
117  group_address_color_temp = config.get(LightSchema.CONF_COLOR_TEMP_ADDRESS)
118  group_address_color_temp_state = config.get(
119  LightSchema.CONF_COLOR_TEMP_STATE_ADDRESS
120  )
121  if config[LightSchema.CONF_COLOR_TEMP_MODE] == ColorTempModes.ABSOLUTE_FLOAT:
122  color_temperature_type = ColorTemperatureType.FLOAT_2_BYTE
123 
124  return XknxLight(
125  xknx,
126  name=config[CONF_NAME],
127  group_address_switch=config.get(KNX_ADDRESS),
128  group_address_switch_state=config.get(LightSchema.CONF_STATE_ADDRESS),
129  group_address_brightness=config.get(LightSchema.CONF_BRIGHTNESS_ADDRESS),
130  group_address_brightness_state=config.get(
131  LightSchema.CONF_BRIGHTNESS_STATE_ADDRESS
132  ),
133  group_address_color=config.get(LightSchema.CONF_COLOR_ADDRESS),
134  group_address_color_state=config.get(LightSchema.CONF_COLOR_STATE_ADDRESS),
135  group_address_rgbw=config.get(LightSchema.CONF_RGBW_ADDRESS),
136  group_address_rgbw_state=config.get(LightSchema.CONF_RGBW_STATE_ADDRESS),
137  group_address_hue=config.get(LightSchema.CONF_HUE_ADDRESS),
138  group_address_hue_state=config.get(LightSchema.CONF_HUE_STATE_ADDRESS),
139  group_address_saturation=config.get(LightSchema.CONF_SATURATION_ADDRESS),
140  group_address_saturation_state=config.get(
141  LightSchema.CONF_SATURATION_STATE_ADDRESS
142  ),
143  group_address_xyy_color=config.get(LightSchema.CONF_XYY_ADDRESS),
144  group_address_xyy_color_state=config.get(LightSchema.CONF_XYY_STATE_ADDRESS),
145  group_address_tunable_white=group_address_tunable_white,
146  group_address_tunable_white_state=group_address_tunable_white_state,
147  group_address_color_temperature=group_address_color_temp,
148  group_address_color_temperature_state=group_address_color_temp_state,
149  group_address_switch_red=individual_color_addresses(
150  LightSchema.CONF_RED, KNX_ADDRESS
151  ),
152  group_address_switch_red_state=individual_color_addresses(
153  LightSchema.CONF_RED, LightSchema.CONF_STATE_ADDRESS
154  ),
155  group_address_brightness_red=individual_color_addresses(
156  LightSchema.CONF_RED, LightSchema.CONF_BRIGHTNESS_ADDRESS
157  ),
158  group_address_brightness_red_state=individual_color_addresses(
159  LightSchema.CONF_RED, LightSchema.CONF_BRIGHTNESS_STATE_ADDRESS
160  ),
161  group_address_switch_green=individual_color_addresses(
162  LightSchema.CONF_GREEN, KNX_ADDRESS
163  ),
164  group_address_switch_green_state=individual_color_addresses(
165  LightSchema.CONF_GREEN, LightSchema.CONF_STATE_ADDRESS
166  ),
167  group_address_brightness_green=individual_color_addresses(
168  LightSchema.CONF_GREEN, LightSchema.CONF_BRIGHTNESS_ADDRESS
169  ),
170  group_address_brightness_green_state=individual_color_addresses(
171  LightSchema.CONF_GREEN, LightSchema.CONF_BRIGHTNESS_STATE_ADDRESS
172  ),
173  group_address_switch_blue=individual_color_addresses(
174  LightSchema.CONF_BLUE, KNX_ADDRESS
175  ),
176  group_address_switch_blue_state=individual_color_addresses(
177  LightSchema.CONF_BLUE, LightSchema.CONF_STATE_ADDRESS
178  ),
179  group_address_brightness_blue=individual_color_addresses(
180  LightSchema.CONF_BLUE, LightSchema.CONF_BRIGHTNESS_ADDRESS
181  ),
182  group_address_brightness_blue_state=individual_color_addresses(
183  LightSchema.CONF_BLUE, LightSchema.CONF_BRIGHTNESS_STATE_ADDRESS
184  ),
185  group_address_switch_white=individual_color_addresses(
186  LightSchema.CONF_WHITE, KNX_ADDRESS
187  ),
188  group_address_switch_white_state=individual_color_addresses(
189  LightSchema.CONF_WHITE, LightSchema.CONF_STATE_ADDRESS
190  ),
191  group_address_brightness_white=individual_color_addresses(
192  LightSchema.CONF_WHITE, LightSchema.CONF_BRIGHTNESS_ADDRESS
193  ),
194  group_address_brightness_white_state=individual_color_addresses(
195  LightSchema.CONF_WHITE, LightSchema.CONF_BRIGHTNESS_STATE_ADDRESS
196  ),
197  color_temperature_type=color_temperature_type,
198  min_kelvin=config[LightSchema.CONF_MIN_KELVIN],
199  max_kelvin=config[LightSchema.CONF_MAX_KELVIN],
200  )
201 
202 
203 def _create_ui_light(xknx: XKNX, knx_config: ConfigType, name: str) -> XknxLight:
204  """Return a KNX Light device to be used within XKNX."""
205 
206  def get_write(key: str) -> str | None:
207  """Get the write group address."""
208  return knx_config[key][CONF_GA_WRITE] if key in knx_config else None
209 
210  def get_state(key: str) -> list[Any] | None:
211  """Get the state group address."""
212  return (
213  [knx_config[key][CONF_GA_STATE], *knx_config[key][CONF_GA_PASSIVE]]
214  if key in knx_config
215  else None
216  )
217 
218  def get_dpt(key: str) -> str | None:
219  """Get the DPT."""
220  return knx_config[key].get(CONF_DPT) if key in knx_config else None
221 
222  group_address_tunable_white = None
223  group_address_tunable_white_state = None
224  group_address_color_temp = None
225  group_address_color_temp_state = None
226  color_temperature_type = ColorTemperatureType.UINT_2_BYTE
227  if ga_color_temp := knx_config.get(CONF_GA_COLOR_TEMP):
228  if ga_color_temp[CONF_DPT] == ColorTempModes.RELATIVE.value:
229  group_address_tunable_white = ga_color_temp[CONF_GA_WRITE]
230  group_address_tunable_white_state = [
231  ga_color_temp[CONF_GA_STATE],
232  *ga_color_temp[CONF_GA_PASSIVE],
233  ]
234  else:
235  # absolute uint or float
236  group_address_color_temp = ga_color_temp[CONF_GA_WRITE]
237  group_address_color_temp_state = [
238  ga_color_temp[CONF_GA_STATE],
239  *ga_color_temp[CONF_GA_PASSIVE],
240  ]
241  if ga_color_temp[CONF_DPT] == ColorTempModes.ABSOLUTE_FLOAT.value:
242  color_temperature_type = ColorTemperatureType.FLOAT_2_BYTE
243 
244  _color_dpt = get_dpt(CONF_GA_COLOR)
245  return XknxLight(
246  xknx,
247  name=name,
248  group_address_switch=get_write(CONF_GA_SWITCH),
249  group_address_switch_state=get_state(CONF_GA_SWITCH),
250  group_address_brightness=get_write(CONF_GA_BRIGHTNESS),
251  group_address_brightness_state=get_state(CONF_GA_BRIGHTNESS),
252  group_address_color=get_write(CONF_GA_COLOR)
253  if _color_dpt == LightColorMode.RGB
254  else None,
255  group_address_color_state=get_state(CONF_GA_COLOR)
256  if _color_dpt == LightColorMode.RGB
257  else None,
258  group_address_rgbw=get_write(CONF_GA_COLOR)
259  if _color_dpt == LightColorMode.RGBW
260  else None,
261  group_address_rgbw_state=get_state(CONF_GA_COLOR)
262  if _color_dpt == LightColorMode.RGBW
263  else None,
264  group_address_hue=get_write(CONF_GA_HUE),
265  group_address_hue_state=get_state(CONF_GA_HUE),
266  group_address_saturation=get_write(CONF_GA_SATURATION),
267  group_address_saturation_state=get_state(CONF_GA_SATURATION),
268  group_address_xyy_color=get_write(CONF_GA_COLOR)
269  if _color_dpt == LightColorMode.XYY
270  else None,
271  group_address_xyy_color_state=get_write(CONF_GA_COLOR)
272  if _color_dpt == LightColorMode.XYY
273  else None,
274  group_address_tunable_white=group_address_tunable_white,
275  group_address_tunable_white_state=group_address_tunable_white_state,
276  group_address_color_temperature=group_address_color_temp,
277  group_address_color_temperature_state=group_address_color_temp_state,
278  group_address_switch_red=get_write(CONF_GA_RED_SWITCH),
279  group_address_switch_red_state=get_state(CONF_GA_RED_SWITCH),
280  group_address_brightness_red=get_write(CONF_GA_RED_BRIGHTNESS),
281  group_address_brightness_red_state=get_state(CONF_GA_RED_BRIGHTNESS),
282  group_address_switch_green=get_write(CONF_GA_GREEN_SWITCH),
283  group_address_switch_green_state=get_state(CONF_GA_GREEN_SWITCH),
284  group_address_brightness_green=get_write(CONF_GA_GREEN_BRIGHTNESS),
285  group_address_brightness_green_state=get_state(CONF_GA_GREEN_BRIGHTNESS),
286  group_address_switch_blue=get_write(CONF_GA_BLUE_SWITCH),
287  group_address_switch_blue_state=get_state(CONF_GA_BLUE_SWITCH),
288  group_address_brightness_blue=get_write(CONF_GA_BLUE_BRIGHTNESS),
289  group_address_brightness_blue_state=get_state(CONF_GA_BLUE_BRIGHTNESS),
290  group_address_switch_white=get_write(CONF_GA_WHITE_SWITCH),
291  group_address_switch_white_state=get_state(CONF_GA_WHITE_SWITCH),
292  group_address_brightness_white=get_write(CONF_GA_WHITE_BRIGHTNESS),
293  group_address_brightness_white_state=get_state(CONF_GA_WHITE_BRIGHTNESS),
294  color_temperature_type=color_temperature_type,
295  min_kelvin=knx_config[CONF_COLOR_TEMP_MIN],
296  max_kelvin=knx_config[CONF_COLOR_TEMP_MAX],
297  sync_state=knx_config[CONF_SYNC_STATE],
298  )
299 
300 
302  """Representation of a KNX light."""
303 
304  _attr_max_color_temp_kelvin: int
305  _attr_min_color_temp_kelvin: int
306  _device: XknxLight
307 
308  @property
309  def is_on(self) -> bool:
310  """Return true if light is on."""
311  return bool(self._device.state)
312 
313  @property
314  def brightness(self) -> int | None:
315  """Return the brightness of this light between 0..255."""
316  if self._device.supports_brightness:
317  return self._device.current_brightness
318  if self._device.current_xyy_color is not None:
319  return self._device.current_xyy_color.brightness
320  if self._device.supports_color or self._device.supports_rgbw:
321  rgb, white = self._device.current_color
322  if rgb is None:
323  return white
324  if white is None:
325  return max(rgb)
326  return max(*rgb, white)
327  return None
328 
329  @property
330  def rgb_color(self) -> tuple[int, int, int] | None:
331  """Return the rgb color value [int, int, int]."""
332  if self._device.supports_color:
333  rgb, _ = self._device.current_color
334  if rgb is not None:
335  if not self._device.supports_brightness:
336  # brightness will be calculated from color so color must not hold brightness again
337  return cast(
338  tuple[int, int, int], color_util.match_max_scale((255,), rgb)
339  )
340  return rgb
341  return None
342 
343  @property
344  def rgbw_color(self) -> tuple[int, int, int, int] | None:
345  """Return the rgbw color value [int, int, int, int]."""
346  if self._device.supports_rgbw:
347  rgb, white = self._device.current_color
348  if rgb is not None and white is not None:
349  if not self._device.supports_brightness:
350  # brightness will be calculated from color so color must not hold brightness again
351  return cast(
352  tuple[int, int, int, int],
353  color_util.match_max_scale((255,), (*rgb, white)),
354  )
355  return (*rgb, white)
356  return None
357 
358  @property
359  def hs_color(self) -> tuple[float, float] | None:
360  """Return the hue and saturation color value [float, float]."""
361  # Hue is scaled 0..360 int encoded in 1 byte in KNX (-> only 256 possible values)
362  # Saturation is scaled 0..100 int
363  return self._device.current_hs_color
364 
365  @property
366  def xy_color(self) -> tuple[float, float] | None:
367  """Return the xy color value [float, float]."""
368  if self._device.current_xyy_color is not None:
369  return self._device.current_xyy_color.color
370  return None
371 
372  @property
373  def color_temp_kelvin(self) -> int | None:
374  """Return the color temperature in Kelvin."""
375  if self._device.supports_color_temperature:
376  if kelvin := self._device.current_color_temperature:
377  return int(kelvin)
378  if self._device.supports_tunable_white:
379  relative_ct = self._device.current_tunable_white
380  if relative_ct is not None:
381  return int(
382  self._attr_min_color_temp_kelvin
383  + (
384  (relative_ct / 255)
385  * (
386  self._attr_max_color_temp_kelvin
387  - self._attr_min_color_temp_kelvin
388  )
389  )
390  )
391  return None
392 
393  @cached_property
394  def supported_color_modes(self) -> set[ColorMode]:
395  """Get supported color modes."""
396  color_mode = set()
397  if (
398  self._device.supports_color_temperature
399  or self._device.supports_tunable_white
400  ):
401  color_mode.add(ColorMode.COLOR_TEMP)
402  if self._device.supports_xyy_color:
403  color_mode.add(ColorMode.XY)
404  if self._device.supports_rgbw:
405  color_mode.add(ColorMode.RGBW)
406  elif self._device.supports_color:
407  # one of RGB or RGBW so individual color configurations work properly
408  color_mode.add(ColorMode.RGB)
409  if self._device.supports_hs_color:
410  color_mode.add(ColorMode.HS)
411  if not color_mode:
412  # brightness or on/off must be the only supported mode
413  if self._device.supports_brightness:
414  color_mode.add(ColorMode.BRIGHTNESS)
415  else:
416  color_mode.add(ColorMode.ONOFF)
417  return color_mode
418 
419  async def async_turn_on(self, **kwargs: Any) -> None:
420  """Turn the light on."""
421  brightness = kwargs.get(ATTR_BRIGHTNESS)
422  # LightEntity color translation will ensure that only attributes of supported
423  # color modes are passed to this method - so we can't set unsupported mode here
424  if color_temp := kwargs.get(ATTR_COLOR_TEMP_KELVIN):
425  self._attr_color_mode_attr_color_mode = ColorMode.COLOR_TEMP
426  if rgb := kwargs.get(ATTR_RGB_COLOR):
427  self._attr_color_mode_attr_color_mode = ColorMode.RGB
428  if rgbw := kwargs.get(ATTR_RGBW_COLOR):
429  self._attr_color_mode_attr_color_mode = ColorMode.RGBW
430  if hs_color := kwargs.get(ATTR_HS_COLOR):
431  self._attr_color_mode_attr_color_mode = ColorMode.HS
432  if xy_color := kwargs.get(ATTR_XY_COLOR):
433  self._attr_color_mode_attr_color_mode = ColorMode.XY
434 
435  if (
436  not self.is_onis_onis_on
437  and brightness is None
438  and color_temp is None
439  and rgb is None
440  and rgbw is None
441  and hs_color is None
442  and xy_color is None
443  ):
444  await self._device.set_on()
445  return
446 
447  async def set_color(
448  rgb: tuple[int, int, int], white: int | None, brightness: int | None
449  ) -> None:
450  """Set color of light. Normalize colors for brightness when not writable."""
451  if self._device.brightness.writable:
452  # let the KNX light controller handle brightness
453  await self._device.set_color(rgb, white)
454  if brightness:
455  await self._device.set_brightness(brightness)
456  return
457 
458  if brightness is None:
459  # normalize for brightness if brightness is derived from color
460  brightness = self.brightnessbrightnessbrightness or 255
461  rgb = cast(
462  tuple[int, int, int],
463  tuple(color * brightness // 255 for color in rgb),
464  )
465  white = white * brightness // 255 if white is not None else None
466  await self._device.set_color(rgb, white)
467 
468  # return after RGB(W) color has changed as it implicitly sets the brightness
469  if rgbw is not None:
470  await set_color(rgbw[:3], rgbw[3], brightness)
471  return
472  if rgb is not None:
473  await set_color(rgb, None, brightness)
474  return
475 
476  if color_temp is not None:
477  color_temp = min(
478  self._attr_max_color_temp_kelvin,
479  max(self._attr_min_color_temp_kelvin, color_temp),
480  )
481  if self._device.supports_color_temperature:
482  await self._device.set_color_temperature(color_temp)
483  elif self._device.supports_tunable_white:
484  relative_ct = round(
485  255
486  * (color_temp - self._attr_min_color_temp_kelvin)
487  / (
488  self._attr_max_color_temp_kelvin
489  - self._attr_min_color_temp_kelvin
490  )
491  )
492  await self._device.set_tunable_white(relative_ct)
493 
494  if xy_color is not None:
495  await self._device.set_xyy_color(
496  XYYColor(color=xy_color, brightness=brightness)
497  )
498  return
499 
500  if hs_color is not None:
501  # round so only one telegram will be sent if the other matches state
502  hue = round(hs_color[0])
503  sat = round(hs_color[1])
504  await self._device.set_hs_color((hue, sat))
505 
506  if brightness is not None:
507  # brightness: 1..255; 0 brightness will call async_turn_off()
508  if self._device.brightness.writable:
509  await self._device.set_brightness(brightness)
510  return
511  # brightness without color in kwargs; set via color
512  if self._attr_color_mode_attr_color_mode == ColorMode.XY:
513  await self._device.set_xyy_color(XYYColor(brightness=brightness))
514  return
515  # default to white if color not known for RGB(W)
516  if self._attr_color_mode_attr_color_mode == ColorMode.RGBW:
517  _rgbw = self.rgbw_colorrgbw_colorrgbw_color
518  if not _rgbw or not any(_rgbw):
519  _rgbw = (0, 0, 0, 255)
520  await set_color(_rgbw[:3], _rgbw[3], brightness)
521  return
522  if self._attr_color_mode_attr_color_mode == ColorMode.RGB:
523  _rgb = self.rgb_colorrgb_colorrgb_color
524  if not _rgb or not any(_rgb):
525  _rgb = (255, 255, 255)
526  await set_color(_rgb, None, brightness)
527  return
528 
529  async def async_turn_off(self, **kwargs: Any) -> None:
530  """Turn the light off."""
531  await self._device.set_off()
532 
533 
535  """Representation of a KNX light."""
536 
537  _device: XknxLight
538 
539  def __init__(self, knx_module: KNXModule, config: ConfigType) -> None:
540  """Initialize of KNX light."""
541  super().__init__(
542  knx_module=knx_module,
543  device=_create_yaml_light(knx_module.xknx, config),
544  )
545  self._attr_color_mode_attr_color_mode_attr_color_mode = next(iter(self.supported_color_modessupported_color_modessupported_color_modes))
546  self._attr_max_color_temp_kelvin: int = config[LightSchema.CONF_MAX_KELVIN]
547  self._attr_min_color_temp_kelvin: int = config[LightSchema.CONF_MIN_KELVIN]
548  self._attr_entity_category_attr_entity_category = config.get(CONF_ENTITY_CATEGORY)
549  self._attr_unique_id_attr_unique_id = self._device_unique_id_device_unique_id()
550 
551  def _device_unique_id(self) -> str:
552  """Return unique id for this device."""
553  if self._device_device.switch.group_address is not None:
554  return f"{self._device.switch.group_address}"
555  return (
556  f"{self._device.red.brightness.group_address}_"
557  f"{self._device.green.brightness.group_address}_"
558  f"{self._device.blue.brightness.group_address}"
559  )
560 
561 
563  """Representation of a KNX light."""
564 
565  _device: XknxLight
566 
567  def __init__(
568  self, knx_module: KNXModule, unique_id: str, config: ConfigType
569  ) -> None:
570  """Initialize of KNX light."""
571  super().__init__(
572  knx_module=knx_module,
573  unique_id=unique_id,
574  entity_config=config[CONF_ENTITY],
575  )
576  self._device_device = _create_ui_light(
577  knx_module.xknx, config[DOMAIN], config[CONF_ENTITY][CONF_NAME]
578  )
579  self._attr_color_mode_attr_color_mode_attr_color_mode = next(iter(self.supported_color_modessupported_color_modessupported_color_modes))
580  self._attr_max_color_temp_kelvin: int = config[DOMAIN][CONF_COLOR_TEMP_MAX]
581  self._attr_min_color_temp_kelvin: int = config[DOMAIN][CONF_COLOR_TEMP_MIN]
None __init__(self, KNXModule knx_module, str unique_id, ConfigType config)
Definition: light.py:569
None __init__(self, KNXModule knx_module, ConfigType config)
Definition: light.py:539
tuple[float, float]|None xy_color(self)
Definition: light.py:366
tuple[int, int, int]|None rgb_color(self)
Definition: light.py:330
None async_turn_on(self, **Any kwargs)
Definition: light.py:419
tuple[int, int, int, int]|None rgbw_color(self)
Definition: light.py:344
set[ColorMode] supported_color_modes(self)
Definition: light.py:394
None async_turn_off(self, **Any kwargs)
Definition: light.py:529
tuple[float, float]|None hs_color(self)
Definition: light.py:359
tuple[int, int, int]|None rgb_color(self)
Definition: __init__.py:957
tuple[int, int, int, int]|None rgbw_color(self)
Definition: __init__.py:962
set[ColorMode]|set[str]|None supported_color_modes(self)
Definition: __init__.py:1302
web.Response get(self, web.Request request, str config_key)
Definition: view.py:88
str|float get_state(dict[str, float] data, str key)
Definition: sensor.py:26
None async_setup_entry(HomeAssistant hass, config_entries.ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Definition: light.py:65
XknxLight _create_yaml_light(XKNX xknx, ConfigType config)
Definition: light.py:93
XknxLight _create_ui_light(XKNX xknx, ConfigType knx_config, str name)
Definition: light.py:203