mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 19:54:14 +01:00
8e75980ebd
* Cleanup dashboard JS * Add vscode * Save start_mark/end_mark * Updates * Updates * Remove need for cv.nameable It's a bit hacky but removes so much bloat from integrations * Add enum helper * Document APIs, and Improvements * Fixes * Fixes * Update PULL_REQUEST_TEMPLATE.md * Updates * Updates * Updates
26 lines
959 B
Python
26 lines
959 B
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
|
|
|
|
rgb_ns = cg.esphome_ns.namespace('rgb')
|
|
RGBLightOutput = rgb_ns.class_('RGBLightOutput', light.LightOutput)
|
|
|
|
CONFIG_SCHEMA = light.RGB_LIGHT_SCHEMA.extend({
|
|
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(RGBLightOutput),
|
|
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),
|
|
})
|
|
|
|
|
|
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))
|