mirror of
https://github.com/esphome/esphome.git
synced 2024-12-03 20:24:14 +01:00
e5d4e12457
* Update light_color_values.h * Update light_color_values.h * Update light_color_values.h * Update light_color_values.h * colour relative to white value * Update light_state.cpp * Update light_state.cpp * Update light_state.cpp * Update light_state.cpp * Update light_color_values.h * Update light_state.cpp * linting * Update light_state.cpp * Update light_color_values.h * more lint * more lint * Update light_state.cpp * Update light_state.cpp * Update light_state.cpp * add optional interlock * Update test1.yaml * Update light_state.cpp * Update light_state.h * interlock * optional interlock. * interlock as trait * color interlock as trait * optional color interlock.... * optional color interlock * Update light_color_values.h * Lint checks.... * making travis happy * making sure gamma_correct fix is included * Update light_color_values.h * making travis happy * clang-format * Code tidy * Update light_color_values.h * Update light_color_values.h
32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import light, output
|
|
from esphome.const import CONF_BLUE, CONF_GREEN, CONF_RED, CONF_OUTPUT_ID, CONF_WHITE
|
|
|
|
rgbw_ns = cg.esphome_ns.namespace('rgbw')
|
|
RGBWLightOutput = rgbw_ns.class_('RGBWLightOutput', light.LightOutput)
|
|
CONF_COLOR_INTERLOCK = 'color_interlock'
|
|
|
|
CONFIG_SCHEMA = light.RGB_LIGHT_SCHEMA.extend({
|
|
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(RGBWLightOutput),
|
|
cv.Required(CONF_RED): cv.use_id(output.FloatOutput),
|
|
cv.Required(CONF_GREEN): cv.use_id(output.FloatOutput),
|
|
cv.Required(CONF_BLUE): cv.use_id(output.FloatOutput),
|
|
cv.Required(CONF_WHITE): cv.use_id(output.FloatOutput),
|
|
cv.Optional(CONF_COLOR_INTERLOCK, default=False): cv.boolean,
|
|
})
|
|
|
|
|
|
def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_OUTPUT_ID])
|
|
yield light.register_light(var, config)
|
|
|
|
red = yield cg.get_variable(config[CONF_RED])
|
|
cg.add(var.set_red(red))
|
|
green = yield cg.get_variable(config[CONF_GREEN])
|
|
cg.add(var.set_green(green))
|
|
blue = yield cg.get_variable(config[CONF_BLUE])
|
|
cg.add(var.set_blue(blue))
|
|
white = yield cg.get_variable(config[CONF_WHITE])
|
|
cg.add(var.set_white(white))
|
|
cg.add(var.set_color_interlock(config[CONF_COLOR_INTERLOCK]))
|