ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
rgbct_light_output.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome::rgbct {
9
11 public:
12 void set_red(output::FloatOutput *red) { red_ = red; }
13 void set_green(output::FloatOutput *green) { green_ = green; }
14 void set_blue(output::FloatOutput *blue) { blue_ = blue; }
15
16 void set_color_temperature(output::FloatOutput *color_temperature) { color_temperature_ = color_temperature; }
17 void set_white_brightness(output::FloatOutput *white_brightness) { white_brightness_ = white_brightness; }
18
19 void set_cold_white_temperature(float cold_white_temperature) { cold_white_temperature_ = cold_white_temperature; }
20 void set_warm_white_temperature(float warm_white_temperature) { warm_white_temperature_ = warm_white_temperature; }
21 void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
22
24 auto traits = light::LightTraits();
25 if (this->color_interlock_) {
26 traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::COLOR_TEMPERATURE});
27 } else {
29 }
30 traits.set_min_mireds(this->cold_white_temperature_);
31 traits.set_max_mireds(this->warm_white_temperature_);
32 return traits;
33 }
35 float red, green, blue, color_temperature, white_brightness;
36
37 state->current_values_as_rgbct(&red, &green, &blue, &color_temperature, &white_brightness);
38
39 this->red_->set_level(red);
40 this->green_->set_level(green);
41 this->blue_->set_level(blue);
42 this->color_temperature_->set_level(color_temperature);
43 this->white_brightness_->set_level(white_brightness);
44 }
45
46 protected:
54 bool color_interlock_{true};
55};
56
57} // namespace esphome::rgbct
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_cold_white_temperature(float cold_white_temperature)
void set_warm_white_temperature(float warm_white_temperature)
void write_state(light::LightState *state) override
output::FloatOutput * color_temperature_
output::FloatOutput * white_brightness_
void set_color_temperature(output::FloatOutput *color_temperature)
void set_color_interlock(bool color_interlock)
void set_white_brightness(output::FloatOutput *white_brightness)
void set_blue(output::FloatOutput *blue)
void set_red(output::FloatOutput *red)
void set_green(output::FloatOutput *green)
light::LightTraits get_traits() override
bool state
Definition fan.h:2
@ RGB_COLOR_TEMPERATURE
RGB color output and a separate white output with controllable color temperature.
@ RGB
RGB color output.
@ COLOR_TEMPERATURE
Controllable color temperature output.