ESPHome 2025.5.0
Loading...
Searching...
No Matches
rgbww_light_output.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace rgbww {
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_cold_white(output::FloatOutput *cold_white) { cold_white_ = cold_white; }
16 void set_warm_white(output::FloatOutput *warm_white) { warm_white_ = warm_white; }
17 void set_cold_white_temperature(float cold_white_temperature) { cold_white_temperature_ = cold_white_temperature; }
18 void set_warm_white_temperature(float warm_white_temperature) { warm_white_temperature_ = warm_white_temperature; }
19 void set_constant_brightness(bool constant_brightness) { constant_brightness_ = constant_brightness; }
20 void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
22 auto traits = light::LightTraits();
23 if (this->color_interlock_) {
24 traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::COLD_WARM_WHITE});
25 } else {
26 traits.set_supported_color_modes({light::ColorMode::RGB_COLD_WARM_WHITE});
27 }
28 traits.set_min_mireds(this->cold_white_temperature_);
29 traits.set_max_mireds(this->warm_white_temperature_);
30 return traits;
31 }
33 float red, green, blue, cwhite, wwhite;
34 state->current_values_as_rgbww(&red, &green, &blue, &cwhite, &wwhite, this->constant_brightness_);
35 this->red_->set_level(red);
36 this->green_->set_level(green);
37 this->blue_->set_level(blue);
38 this->cold_white_->set_level(cwhite);
39 this->warm_white_->set_level(wwhite);
40 }
41
42 protected:
51 bool color_interlock_{false};
52};
53
54} // namespace rgbww
55} // 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_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:0
@ 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.
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7