ESPHome  2024.12.2
rgbct_light_output.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 namespace esphome {
9 namespace 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
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition: light_state.h:63
light::LightTraits get_traits() override
Interface to write LightStates to hardware.
Definition: light_output.h:12
Base class for all output components that can output a variable level, like PWM.
Definition: float_output.h:31
output::FloatOutput * white_brightness_
Color temperature can be controlled.
void set_blue(output::FloatOutput *blue)
void set_green(output::FloatOutput *green)
void set_level(float state)
Set the level of this float output, this is called from the front-end.
void current_values_as_rgbct(float *red, float *green, float *blue, float *color_temperature, float *white_brightness)
void set_cold_white_temperature(float cold_white_temperature)
void set_color_interlock(bool color_interlock)
RGB color output and a separate white output with controllable color temperature. ...
void set_warm_white_temperature(float warm_white_temperature)
This class is used to represent the capabilities of a light.
Definition: light_traits.h:11
void set_white_brightness(output::FloatOutput *white_brightness)
void set_color_temperature(output::FloatOutput *color_temperature)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_red(output::FloatOutput *red)
Color can be controlled using RGB format (includes a brightness control for the color).
output::FloatOutput * color_temperature_
void write_state(light::LightState *state) override
bool state
Definition: fan.h:34