first empty components
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#include "esphome.h"
|
||||
#include "empty_custom_light.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_custom_light {
|
||||
|
||||
void EmptyCustomLightOutput::setup() {
|
||||
|
||||
}
|
||||
|
||||
light::LightTraits EmptyCustomLightOutput::get_traits() {
|
||||
auto traits = light::LightTraits();
|
||||
traits.set_supports_brightness(true);
|
||||
traits.set_supports_rgb(false);
|
||||
traits.set_supports_rgb_white_value(false);
|
||||
traits.set_supports_color_temperature(false);
|
||||
|
||||
return traits;
|
||||
}
|
||||
|
||||
void EmptyCustomLightOutput::write_state(light::LightState *state) {
|
||||
|
||||
}
|
||||
|
||||
void EmptyCustomLightOutput::dump_config(){
|
||||
|
||||
}
|
||||
|
||||
} //namespace empty_custom_light
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/light/light_output.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_custom_light {
|
||||
|
||||
class EmptyCustomLightOutput : public light::LightOutput, public Component {
|
||||
public:
|
||||
void setup() override;
|
||||
light::LightTraits get_traits() override;
|
||||
void set_output(output::FloatOutput *output) { output_ = output; }
|
||||
void write_state(light::LightState *state) override;
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
output::FloatOutput *output_;
|
||||
};
|
||||
|
||||
} //namespace empty_custom_light
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,19 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import light, output
|
||||
from esphome.const import CONF_OUTPUT_ID, CONF_OUTPUT
|
||||
|
||||
empty_custom_light_ns = cg.esphome_ns.namespace('empty_custom_light')
|
||||
EmptyCustomLightOutput = empty_custom_light_ns.class_('EmptyCustomLightOutput', light.LightOutput)
|
||||
|
||||
CONFIG_SCHEMA = light.BRIGHTNESS_ONLY_LIGHT_SCHEMA.extend({
|
||||
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(EmptyCustomLightOutput),
|
||||
cv.Required(CONF_OUTPUT): cv.use_id(output.FloatOutput)
|
||||
})
|
||||
|
||||
def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_OUTPUT_ID])
|
||||
yield light.register_light(var, config)
|
||||
|
||||
out = yield cg.get_variable(config[CONF_OUTPUT])
|
||||
cg.add(var.set_output(out))
|
||||
Reference in New Issue
Block a user