ESPHome 2025.5.0
Loading...
Searching...
No Matches
rgbw_light_output.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace rgbw {
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 void set_white(output::FloatOutput *white) { white_ = white; }
16 void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
18 auto traits = light::LightTraits();
19 if (this->color_interlock_) {
20 traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::WHITE});
21 } else {
22 traits.set_supported_color_modes({light::ColorMode::RGB_WHITE});
23 }
24 return traits;
25 }
27 float red, green, blue, white;
28 state->current_values_as_rgbw(&red, &green, &blue, &white, this->color_interlock_);
29 this->red_->set_level(red);
30 this->green_->set_level(green);
31 this->blue_->set_level(blue);
32 this->white_->set_level(white);
33 }
34
35 protected:
40 bool color_interlock_{false};
41};
42
43} // namespace rgbw
44} // namespace esphome
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:63
This class is used to represent the capabilities of a light.
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:0
@ 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).
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7