ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
rgbww_light_output.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::rgbww {
8
10 public:
11 void set_red(output::FloatOutput *red) { red_ = red; }
12 void set_green(output::FloatOutput *green) { green_ = green; }
13 void set_blue(output::FloatOutput *blue) { blue_ = blue; }
14 void set_cold_white(output::FloatOutput *cold_white) { cold_white_ = cold_white; }
15 void set_warm_white(output::FloatOutput *warm_white) { warm_white_ = warm_white; }
16 void set_cold_white_temperature(float cold_white_temperature) { cold_white_temperature_ = cold_white_temperature; }
17 void set_warm_white_temperature(float warm_white_temperature) { warm_white_temperature_ = warm_white_temperature; }
18 void set_constant_brightness(bool constant_brightness) { constant_brightness_ = constant_brightness; }
19 void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
21 auto traits = light::LightTraits();
22 if (this->color_interlock_) {
23 traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::COLD_WARM_WHITE});
24 } else {
25 traits.set_supported_color_modes({light::ColorMode::RGB_COLD_WARM_WHITE});
26 }
27 traits.set_min_mireds(this->cold_white_temperature_);
28 traits.set_max_mireds(this->warm_white_temperature_);
29 return traits;
30 }
32 float red, green, blue, cwhite, wwhite;
33 state->current_values_as_rgbww(&red, &green, &blue, &cwhite, &wwhite, this->constant_brightness_);
34 this->red_->set_level(red);
35 this->green_->set_level(green);
36 this->blue_->set_level(blue);
37 this->cold_white_->set_level(cwhite);
38 this->warm_white_->set_level(wwhite);
39 }
40
41 protected:
50 bool color_interlock_{false};
51};
52
53} // namespace esphome::rgbww
Interface to write LightStates to hardware.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition light_state.h:93
This class is used to represent the capabilities of a light.
Definition light_traits.h:9
Base class for all output components that can output a variable level, like PWM.
void set_level(float state)
Set the level of this float output, this is called from the front-end.
void set_warm_white(output::FloatOutput *warm_white)
void set_constant_brightness(bool constant_brightness)
light::LightTraits get_traits() override
void set_cold_white(output::FloatOutput *cold_white)
void set_cold_white_temperature(float cold_white_temperature)
void set_blue(output::FloatOutput *blue)
void set_color_interlock(bool color_interlock)
void set_green(output::FloatOutput *green)
void write_state(light::LightState *state) override
void set_warm_white_temperature(float warm_white_temperature)
void set_red(output::FloatOutput *red)
bool state
Definition fan.h:2
@ RGB_COLD_WARM_WHITE
RGB color output, and separate cold and warm white outputs.
@ RGB
RGB color output.
@ COLD_WARM_WHITE
Cold and warm white output with individually controllable brightness.