mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
Add get/set color temperature functions in Kelvin (#5006)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
1775c73e53
commit
41b19504bc
1 changed files with 15 additions and 0 deletions
|
@ -266,6 +266,21 @@ class LightColorValues {
|
||||||
/// Set the color temperature property of these light color values in mired.
|
/// Set the color temperature property of these light color values in mired.
|
||||||
void set_color_temperature(float color_temperature) { this->color_temperature_ = color_temperature; }
|
void set_color_temperature(float color_temperature) { this->color_temperature_ = color_temperature; }
|
||||||
|
|
||||||
|
/// Get the color temperature property of these light color values in kelvin.
|
||||||
|
float get_color_temperature_kelvin() const {
|
||||||
|
if (this->color_temperature_ <= 0) {
|
||||||
|
return this->color_temperature_;
|
||||||
|
}
|
||||||
|
return 1000000.0 / this->color_temperature_;
|
||||||
|
}
|
||||||
|
/// Set the color temperature property of these light color values in kelvin.
|
||||||
|
void set_color_temperature_kelvin(float color_temperature) {
|
||||||
|
if (color_temperature <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->color_temperature_ = 1000000.0 / color_temperature;
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the cold white property of these light color values. In range 0.0 to 1.0.
|
/// Get the cold white property of these light color values. In range 0.0 to 1.0.
|
||||||
float get_cold_white() const { return this->cold_white_; }
|
float get_cold_white() const { return this->cold_white_; }
|
||||||
/// Set the cold white property of these light color values. In range 0.0 to 1.0.
|
/// Set the cold white property of these light color values. In range 0.0 to 1.0.
|
||||||
|
|
Loading…
Reference in a new issue