ESPHome 2025.5.0
Loading...
Searching...
No Matches
light_traits.h
Go to the documentation of this file.
1#pragma once
2
4#include "color_mode.h"
5#include <set>
6
7namespace esphome {
8namespace light {
9
12 public:
13 LightTraits() = default;
14
15 const std::set<ColorMode> &get_supported_color_modes() const { return this->supported_color_modes_; }
16 void set_supported_color_modes(std::set<ColorMode> supported_color_modes) {
17 this->supported_color_modes_ = std::move(supported_color_modes);
18 }
19
20 bool supports_color_mode(ColorMode color_mode) const { return this->supported_color_modes_.count(color_mode); }
21 bool supports_color_capability(ColorCapability color_capability) const {
22 for (auto mode : this->supported_color_modes_) {
23 if (mode & color_capability)
24 return true;
25 }
26 return false;
27 }
28
29 ESPDEPRECATED("get_supports_brightness() is deprecated, use color modes instead.", "v1.21")
30 bool get_supports_brightness() const { return this->supports_color_capability(ColorCapability::BRIGHTNESS); }
31 ESPDEPRECATED("get_supports_rgb() is deprecated, use color modes instead.", "v1.21")
32 bool get_supports_rgb() const { return this->supports_color_capability(ColorCapability::RGB); }
33 ESPDEPRECATED("get_supports_rgb_white_value() is deprecated, use color modes instead.", "v1.21")
34 bool get_supports_rgb_white_value() const {
37 }
38 ESPDEPRECATED("get_supports_color_temperature() is deprecated, use color modes instead.", "v1.21")
39 bool get_supports_color_temperature() const {
41 }
42 ESPDEPRECATED("get_supports_color_interlock() is deprecated, use color modes instead.", "v1.21")
43 bool get_supports_color_interlock() const {
44 return this->supports_color_mode(ColorMode::RGB) &&
47 }
48
49 float get_min_mireds() const { return this->min_mireds_; }
50 void set_min_mireds(float min_mireds) { this->min_mireds_ = min_mireds; }
51 float get_max_mireds() const { return this->max_mireds_; }
52 void set_max_mireds(float max_mireds) { this->max_mireds_ = max_mireds; }
53
54 protected:
55 std::set<ColorMode> supported_color_modes_{};
56 float min_mireds_{0};
57 float max_mireds_{0};
58};
59
60} // namespace light
61} // namespace esphome
BedjetMode mode
BedJet operating mode.
This class is used to represent the capabilities of a light.
ESPDEPRECATED("get_supports_brightness() is deprecated, use color modes instead.", "v1.21") bool get_supports_brightness() const
ESPDEPRECATED("get_supports_rgb() is deprecated, use color modes instead.", "v1.21") bool get_supports_rgb() const
ESPDEPRECATED("get_supports_color_temperature() is deprecated, use color modes instead.", "v1.21") bool get_supports_color_temperature() const
ESPDEPRECATED("get_supports_rgb_white_value() is deprecated, use color modes instead.", "v1.21") bool get_supports_rgb_white_value() const
bool supports_color_mode(ColorMode color_mode) const
const std::set< ColorMode > & get_supported_color_modes() const
ESPDEPRECATED("get_supports_color_interlock() is deprecated, use color modes instead.", "v1.21") bool get_supports_color_interlock() const
void set_min_mireds(float min_mireds)
bool supports_color_capability(ColorCapability color_capability) const
void set_supported_color_modes(std::set< ColorMode > supported_color_modes)
std::set< ColorMode > supported_color_modes_
void set_max_mireds(float max_mireds)
ColorMode
Color modes are a combination of color capabilities that can be used at the same time.
Definition color_mode.h:49
@ RGB_WHITE
RGB color output and a separate white output.
@ 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.
@ WHITE
White output only (use only if the light also has another color mode such as RGB).
@ COLD_WARM_WHITE
Cold and warm white output with individually controllable brightness.
ColorCapability
Color capabilities are the various outputs that a light has and that can be independently controlled ...
Definition color_mode.h:9
@ BRIGHTNESS
Master brightness of the light can be controlled.
@ RGB
Color can be controlled using RGB format (includes a brightness control for the color).
@ COLOR_TEMPERATURE
Color temperature can be controlled.
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7