ESPHome 2025.5.0
Loading...
Searching...
No Matches
fan_traits.h
Go to the documentation of this file.
1#include <set>
2#include <utility>
3
4#pragma once
5
6namespace esphome {
7namespace fan {
8
9class FanTraits {
10 public:
11 FanTraits() = default;
12 FanTraits(bool oscillation, bool speed, bool direction, int speed_count)
13 : oscillation_(oscillation), speed_(speed), direction_(direction), speed_count_(speed_count) {}
14
16 bool supports_oscillation() const { return this->oscillation_; }
18 void set_oscillation(bool oscillation) { this->oscillation_ = oscillation; }
20 bool supports_speed() const { return this->speed_; }
22 void set_speed(bool speed) { this->speed_ = speed; }
24 int supported_speed_count() const { return this->speed_count_; }
26 void set_supported_speed_count(int speed_count) { this->speed_count_ = speed_count; }
28 bool supports_direction() const { return this->direction_; }
32 std::set<std::string> supported_preset_modes() const { return this->preset_modes_; }
34 void set_supported_preset_modes(const std::set<std::string> &preset_modes) { this->preset_modes_ = preset_modes; }
36 bool supports_preset_modes() const { return !this->preset_modes_.empty(); }
37
38 protected:
39 bool oscillation_{false};
40 bool speed_{false};
41 bool direction_{false};
43 std::set<std::string> preset_modes_{};
44};
45
46} // namespace fan
47} // namespace esphome
void set_direction(bool direction)
Set whether this fan supports changing direction.
Definition fan_traits.h:30
bool supports_preset_modes() const
Return if preset modes are supported.
Definition fan_traits.h:36
void set_speed(bool speed)
Set whether this fan supports speed levels.
Definition fan_traits.h:22
int supported_speed_count() const
Return how many speed levels the fan has.
Definition fan_traits.h:24
void set_supported_speed_count(int speed_count)
Set how many speed levels this fan has.
Definition fan_traits.h:26
bool supports_direction() const
Return if this fan supports changing direction.
Definition fan_traits.h:28
void set_oscillation(bool oscillation)
Set whether this fan supports oscillation.
Definition fan_traits.h:18
bool supports_speed() const
Return if this fan supports speed modes.
Definition fan_traits.h:20
FanTraits(bool oscillation, bool speed, bool direction, int speed_count)
Definition fan_traits.h:12
std::set< std::string > preset_modes_
Definition fan_traits.h:43
void set_supported_preset_modes(const std::set< std::string > &preset_modes)
Set the preset modes supported by the fan.
Definition fan_traits.h:34
std::set< std::string > supported_preset_modes() const
Return the preset modes supported by the fan.
Definition fan_traits.h:32
bool supports_oscillation() const
Return if this fan supports oscillation.
Definition fan_traits.h:16
FanDirection direction
Definition fan.h:3
int speed
Definition fan.h:1
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7