ESPHome 2026.5.1
Loading...
Searching...
No Matches
rgbw_light_output.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::rgbw {
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_white(output::FloatOutput *white) { white_ = white; }
15 void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
17 auto traits = light::LightTraits();
18 if (this->color_interlock_) {
19 traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::WHITE});
20 } else {
21 traits.set_supported_color_modes({light::ColorMode::RGB_WHITE});
22 }
23 return traits;
24 }
26 float red, green, blue, white;
27 state->current_values_as_rgbw(&red, &green, &blue, &white);
28 this->red_->set_level(red);
29 this->green_->set_level(green);
30 this->blue_->set_level(blue);
31 this->white_->set_level(white);
32 }
33
34 protected:
39 bool color_interlock_{false};
40};
41
42} // namespace esphome::rgbw
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_blue(output::FloatOutput *blue)
void set_white(output::FloatOutput *white)
void set_red(output::FloatOutput *red)
light::LightTraits get_traits() override
void write_state(light::LightState *state) override
void set_color_interlock(bool color_interlock)
void set_green(output::FloatOutput *green)
bool state
Definition fan.h:2
@ RGB_WHITE
RGB color output and a separate white output.
@ RGB
RGB color output.
@ WHITE
White output only (use only if the light also has another color mode such as RGB).