Add selection between RGB and color temp

This commit is contained in:
Bas Nijholt 2022-08-31 22:15:24 -07:00 committed by Bas Nijholt
commit 29a4b8a33c
2 changed files with 18 additions and 2 deletions

View file

@ -1,4 +1,5 @@
"""Constants for the Adaptive Lighting integration."""
from homeassistant.components.light import VALID_TRANSITION
from homeassistant.helpers import selector
import homeassistant.helpers.config_validation as cv
@ -84,7 +85,19 @@ VALIDATION_TUPLES = [
DEFAULT_SLEEP_RGB_COLOR,
selector.ColorRGBSelector(selector.ColorRGBSelectorConfig()),
),
(CONF_SLEEP_RGB_OR_COLOR_TEMP, DEFAULT_SLEEP_RGB_OR_COLOR_TEMP, bool),
(
CONF_SLEEP_RGB_OR_COLOR_TEMP,
DEFAULT_SLEEP_RGB_OR_COLOR_TEMP,
selector.SelectSelector(
selector.SelectSelectorConfig(
options=["color_temp", "rgb"],
multiple=False,
mode=selector.SelectSelectorMode.DROPDOWN,
),
)
# vol.Any(vol.Literal("color_temp"), vol.Literal("rgb")),
# cv.multi_select(["color_temp", "rgb_color"]),
),
(CONF_SUNRISE_TIME, NONE_STR, str),
(CONF_SUNRISE_OFFSET, DEFAULT_SUNRISE_OFFSET, int),
(CONF_SUNSET_TIME, NONE_STR, str),

View file

@ -12,7 +12,7 @@ from datetime import timedelta
import functools
import logging
import math
from typing import Any
from typing import Any, Literal
import astral
from homeassistant.components.light import (
@ -114,6 +114,7 @@ from .const import (
CONF_SLEEP_BRIGHTNESS,
CONF_SLEEP_COLOR_TEMP,
CONF_SLEEP_RGB_COLOR,
CONF_SLEEP_RGB_OR_COLOR_TEMP,
CONF_SLEEP_TRANSITION,
CONF_SUNRISE_OFFSET,
CONF_SUNRISE_TIME,
@ -589,6 +590,7 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
sleep_brightness=data[CONF_SLEEP_BRIGHTNESS],
sleep_color_temp=data[CONF_SLEEP_COLOR_TEMP],
sleep_rgb_color=data[CONF_SLEEP_RGB_COLOR],
sleep_rgb_or_color_temp=data[CONF_SLEEP_RGB_OR_COLOR_TEMP],
sunrise_offset=data[CONF_SUNRISE_OFFSET],
sunrise_time=data[CONF_SUNRISE_TIME],
sunset_offset=data[CONF_SUNSET_OFFSET],
@ -1075,6 +1077,7 @@ class SunLightSettings:
min_brightness: int
min_color_temp: int
sleep_brightness: int
sleep_rgb_or_color_temp: Literal["color_temp", "rgb"]
sleep_color_temp: int
sleep_rgb_color: tuple[int, int, int]
sunrise_offset: datetime.timedelta | None