18 void play(Ts...
x)
override {
20 if (this->oscillating_.has_value()) {
23 if (this->speed_.has_value()) {
26 if (this->direction_.has_value()) {
59 void play(Ts...
x)
override {
65 bool off_speed_cycle = no_off_cycle_.value(
x...);
66 if (speed > supported_speed_count && off_speed_cycle) {
72 }
else if (speed > supported_speed_count && !off_speed_cycle) {
125 auto is_on = state->
state;
126 auto should_trigger = is_on && !this->last_on_;
127 this->last_on_ = is_on;
128 if (should_trigger) {
132 this->last_on_ = state->
state;
143 auto is_on = state->
state;
144 auto should_trigger = !is_on && this->last_on_;
145 this->last_on_ = is_on;
146 if (should_trigger) {
150 this->last_on_ = state->
state;
162 auto should_trigger =
direction != this->last_direction_;
164 if (should_trigger) {
168 this->last_direction_ = state->
direction;
180 auto should_trigger =
oscillating != this->last_oscillating_;
182 if (should_trigger) {
198 auto should_trigger =
speed != this->last_speed_;
199 this->last_speed_ =
speed;
200 if (should_trigger) {
201 this->trigger(
speed);
204 this->last_speed_ = state->
speed;
216 auto should_trigger =
preset_mode != this->last_preset_mode_;
218 if (should_trigger) {
TEMPLATABLE_VALUE(bool, oscillating) TEMPLATABLE_VALUE(int
bool state
The current on/off state of the fan.
bool oscillating
The current oscillation state of the fan.
FanDirection direction
The current direction of the fan.
FanTurnOffTrigger(Fan *state)
FanIsOffCondition(Fan *state)
virtual FanTraits get_traits()=0
FanOscillatingSetTrigger(Fan *state)
void play(Ts... x) override
FanDirectionSetTrigger(Fan *state)
FanIsOnCondition(Fan *state)
FanTurnOnTrigger(Fan *state)
int supported_speed_count() const
Return how many speed levels the fan has.
void add_on_state_callback(std::function< void()> &&callback)
Register a callback that will be called each time the state changes.
TEMPLATABLE_VALUE(bool, no_off_cycle) void play(Ts... x) override
void play(Ts... x) override
FanCall & set_speed(int speed)
FanDirection last_direction_
Base class for all automation conditions.
std::string last_preset_mode_
FanDirection
Simple enum to represent the direction of a fan.
bool check(Ts... x) override
int speed
The current fan speed level.
FanCall & set_oscillating(bool oscillating)
FanPresetSetTrigger(Fan *state)
bool check(Ts... x) override
FanSpeedSetTrigger(Fan *state)
TurnOffAction(Fan *state)
Implementation of SPI Controller mode.
FanStateTrigger(Fan *state)
virtual void play(Ts... x)=0
FanCall & set_direction(FanDirection direction)
CycleSpeedAction(Fan *state)