empty sensor rename
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "empty_light.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_light {
|
||||
|
||||
static const char *TAG = "empty_light.light";
|
||||
|
||||
void EmptyLightOutput::setup() {
|
||||
|
||||
}
|
||||
|
||||
light::LightTraits EmptyLightOutput::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 EmptyLightOutput::write_state(light::LightState *state) {
|
||||
|
||||
}
|
||||
|
||||
void EmptyLightOutput::dump_config(){
|
||||
ESP_LOGCONFIG(TAG, "Empty custom light");
|
||||
}
|
||||
|
||||
} //namespace empty_light
|
||||
} //namespace esphome
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/output/float_output.h"
|
||||
#include "esphome/components/light/light_output.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace empty_light {
|
||||
|
||||
class EmptyLightOutput : 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_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_light_ns = cg.esphome_ns.namespace('empty_light')
|
||||
EmptyLightOutput = empty_light_ns.class_('EmptyLightOutput', light.LightOutput)
|
||||
|
||||
CONFIG_SCHEMA = light.BRIGHTNESS_ONLY_LIGHT_SCHEMA.extend({
|
||||
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(EmptyLightOutput),
|
||||
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