1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-19 19:52:20 +01:00

Validate color temperature values for RGBWW/CWWW lights (#1957)

Check if the color temperature of the cold white channel is colder (less) than
the warm white channel.
This commit is contained in:
Oxan van Leeuwen
2021-06-24 00:07:27 +02:00
committed by GitHub
parent 2cb3015a28
commit 7051f897bc
3 changed files with 42 additions and 22 deletions

View File

@@ -16,6 +16,8 @@ from esphome.const import (
CONF_ON_TURN_OFF,
CONF_ON_TURN_ON,
CONF_TRIGGER_ID,
CONF_COLD_WHITE_COLOR_TEMPERATURE,
CONF_WARM_WHITE_COLOR_TEMPERATURE,
)
from esphome.core import coroutine_with_priority
from .automation import light_control_to_code # noqa
@@ -104,6 +106,18 @@ ADDRESSABLE_LIGHT_SCHEMA = RGB_LIGHT_SCHEMA.extend(
)
def validate_color_temperature_channels(value):
if (
value[CONF_COLD_WHITE_COLOR_TEMPERATURE]
>= value[CONF_WARM_WHITE_COLOR_TEMPERATURE]
):
raise cv.Invalid(
"Color temperature of the cold white channel must be colder than that of the warm white channel.",
path=[CONF_COLD_WHITE_COLOR_TEMPERATURE],
)
return value
async def setup_light_core_(light_var, output_var, config):
cg.add(light_var.set_restore_mode(config[CONF_RESTORE_MODE]))
if CONF_INTERNAL in config: