ESPHome 2025.5.0
Loading...
Searching...
No Matches
rgbct_light_output.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome {
9namespace rgbct {
10
12 public:
13 void set_red(output::FloatOutput *red) { red_ = red; }
14 void set_green(output::FloatOutput *green) { green_ = green; }
15 void set_blue(output::FloatOutput *blue) { blue_ = blue; }
16
17 void set_color_temperature(output::FloatOutput *color_temperature) { color_temperature_ = color_temperature; }
18 void set_white_brightness(output::FloatOutput *white_brightness) { white_brightness_ = white_brightness; }
19
20 void set_cold_white_temperature(float cold_white_temperature) { cold_white_temperature_ = cold_white_temperature; }
21 void set_warm_white_temperature(float warm_white_temperature) { warm_white_temperature_ = warm_white_temperature; }
22 void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
23
25 auto traits = light::LightTraits();
26 if (this->color_interlock_) {
27 traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::COLOR_TEMPERATURE});
28 } else {
30 }
31 traits.set_min_mireds(this->cold_white_temperature_);
32 traits.set_max_mireds(this->warm_white_temperature_);
33 return traits;
34 }
36 float red, green, blue, color_temperature, white_brightness;
37
38 state->current_values_as_rgbct(&red, &green, &blue, &color_temperature, &white_brightness);
39
40 this->red_->set_level(red);
41 this->green_->set_level(green);
42 this->blue_->set_level(blue);
43 this->color_temperature_->set_level(color_temperature);
44 this->white_brightness_->set_level(white_brightness);
45 }
46
47 protected:
55 bool color_interlock_{true};
56};
57
58} // namespace rgbct
59} // 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_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:0
@ 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.
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7