mirror of
https://github.com/esphome/esphome.git
synced 2025-10-29 22:24:26 +00:00
Cleanup dashboard JS (#491)
* 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
This commit is contained in:
@@ -6,17 +6,21 @@ 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 = cv.nameable(light.RGB_LIGHT_SCHEMA.extend({
|
||||
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_variable_id(RGBLightOutput),
|
||||
cv.Required(CONF_RED): cv.use_variable_id(output.FloatOutput),
|
||||
cv.Required(CONF_GREEN): cv.use_variable_id(output.FloatOutput),
|
||||
cv.Required(CONF_BLUE): cv.use_variable_id(output.FloatOutput),
|
||||
}))
|
||||
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):
|
||||
red = yield cg.get_variable(config[CONF_RED])
|
||||
green = yield cg.get_variable(config[CONF_GREEN])
|
||||
blue = yield cg.get_variable(config[CONF_BLUE])
|
||||
var = cg.new_Pvariable(config[CONF_OUTPUT_ID], red, green, blue)
|
||||
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))
|
||||
|
||||
@@ -9,8 +9,9 @@ namespace rgb {
|
||||
|
||||
class RGBLightOutput : public light::LightOutput {
|
||||
public:
|
||||
RGBLightOutput(output::FloatOutput *red, output::FloatOutput *green, output::FloatOutput *blue)
|
||||
: red_(red), green_(green), blue_(blue) {}
|
||||
void set_red(output::FloatOutput *red) { red_ = red; }
|
||||
void set_green(output::FloatOutput *green) { green_ = green; }
|
||||
void set_blue(output::FloatOutput *blue) { blue_ = blue; }
|
||||
light::LightTraits get_traits() override {
|
||||
auto traits = light::LightTraits();
|
||||
traits.set_supports_brightness(true);
|
||||
|
||||
Reference in New Issue
Block a user