ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
light_traits.h
Go to the documentation of this file.
1#pragma once
2
3#include "color_mode.h"
5
6namespace esphome {
7
8#ifdef USE_API
9namespace api {
10class APIConnection;
11} // namespace api
12#endif
13
14namespace light {
15
18 public:
19 LightTraits() = default;
20
21 // Return by value to avoid dangling reference when get_traits() returns a temporary
23 void set_supported_color_modes(ColorModeMask supported_color_modes) {
24 this->supported_color_modes_ = supported_color_modes;
25 }
26 void set_supported_color_modes(std::initializer_list<ColorMode> modes) {
28 }
29
30 bool supports_color_mode(ColorMode color_mode) const { return this->supported_color_modes_.count(color_mode) > 0; }
31 bool supports_color_capability(ColorCapability color_capability) const {
32 return has_capability(this->supported_color_modes_, color_capability);
33 }
34
35 float get_min_mireds() const { return this->min_mireds_; }
36 void set_min_mireds(float min_mireds) { this->min_mireds_ = min_mireds; }
37 float get_max_mireds() const { return this->max_mireds_; }
38 void set_max_mireds(float max_mireds) { this->max_mireds_ = max_mireds; }
39
40 protected:
41 float min_mireds_{0};
42 float max_mireds_{0};
44};
45
46} // namespace light
47} // namespace esphome
constexpr size_t count(ValueType value) const
Check if the set contains a specific value (std::set compatibility) Returns 1 if present,...
This class is used to represent the capabilities of a light.
void set_supported_color_modes(ColorModeMask supported_color_modes)
void set_supported_color_modes(std::initializer_list< ColorMode > modes)
bool supports_color_mode(ColorMode color_mode) const
ColorModeMask get_supported_color_modes() const
void set_min_mireds(float min_mireds)
bool supports_color_capability(ColorCapability color_capability) const
ColorModeMask supported_color_modes_
void set_max_mireds(float max_mireds)
FiniteSetMask< ColorMode, ColorModeBitPolicy > ColorModeMask
Definition color_mode.h:148
bool has_capability(const ColorModeMask &mask, ColorCapability capability)
Check if any mode in the bitmask has a specific capability Used for checking if a light supports a ca...
Definition color_mode.h:208
ColorMode
Color modes are a combination of color capabilities that can be used at the same time.
Definition color_mode.h:50
ColorCapability
Color capabilities are the various outputs that a light has and that can be independently controlled ...
Definition color_mode.h:10
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7