mirror of
https://github.com/esphome/esphome.git
synced 2025-11-15 06:15:47 +00:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "color_mode.h"
|
|
#include "esphome/core/helpers.h"
|
|
|
|
namespace esphome {
|
|
|
|
#ifdef USE_API
|
|
namespace api {
|
|
class APIConnection;
|
|
} // namespace api
|
|
#endif
|
|
|
|
namespace light {
|
|
|
|
/// This class is used to represent the capabilities of a light.
|
|
class LightTraits {
|
|
public:
|
|
LightTraits() = default;
|
|
|
|
const ColorModeMask &get_supported_color_modes() const { return this->supported_color_modes_; }
|
|
void set_supported_color_modes(ColorModeMask supported_color_modes) {
|
|
this->supported_color_modes_ = supported_color_modes;
|
|
}
|
|
void set_supported_color_modes(std::initializer_list<ColorMode> modes) {
|
|
this->supported_color_modes_ = ColorModeMask(modes);
|
|
}
|
|
|
|
bool supports_color_mode(ColorMode color_mode) const { return this->supported_color_modes_.count(color_mode) > 0; }
|
|
bool supports_color_capability(ColorCapability color_capability) const {
|
|
return has_capability(this->supported_color_modes_, color_capability);
|
|
}
|
|
|
|
float get_min_mireds() const { return this->min_mireds_; }
|
|
void set_min_mireds(float min_mireds) { this->min_mireds_ = min_mireds; }
|
|
float get_max_mireds() const { return this->max_mireds_; }
|
|
void set_max_mireds(float max_mireds) { this->max_mireds_ = max_mireds; }
|
|
|
|
protected:
|
|
float min_mireds_{0};
|
|
float max_mireds_{0};
|
|
ColorModeMask supported_color_modes_{};
|
|
};
|
|
|
|
} // namespace light
|
|
} // namespace esphome
|