mirror of
https://github.com/esphome/esphome.git
synced 2025-02-21 20:38:16 +00:00
* 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
37 lines
1015 B
C++
37 lines
1015 B
C++
#pragma once
|
|
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/components/output/float_output.h"
|
|
#include "esphome/components/light/light_output.h"
|
|
|
|
namespace esphome {
|
|
namespace rgb {
|
|
|
|
class RGBLightOutput : public light::LightOutput {
|
|
public:
|
|
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);
|
|
traits.set_supports_rgb(true);
|
|
return traits;
|
|
}
|
|
void write_state(light::LightState *state) override {
|
|
float red, green, blue;
|
|
state->current_values_as_rgb(&red, &green, &blue);
|
|
this->red_->set_level(red);
|
|
this->green_->set_level(green);
|
|
this->blue_->set_level(blue);
|
|
}
|
|
|
|
protected:
|
|
output::FloatOutput *red_;
|
|
output::FloatOutput *green_;
|
|
output::FloatOutput *blue_;
|
|
};
|
|
|
|
} // namespace rgb
|
|
} // namespace esphome
|