18 void play(Ts...
x)
override {
20 if (this->oscillating_.has_value()) {
23 if (this->speed_.has_value()) {
26 if (this->direction_.has_value()) {
63 if (speed > supported_speed_count) {
110 auto is_on = state->
state;
111 auto should_trigger = is_on && !this->last_on_;
112 this->last_on_ = is_on;
113 if (should_trigger) {
117 this->last_on_ = state->
state;
128 auto is_on = state->
state;
129 auto should_trigger = !is_on && this->last_on_;
130 this->last_on_ = is_on;
131 if (should_trigger) {
135 this->last_on_ = state->
state;
147 auto should_trigger =
speed != !this->last_speed_;
148 this->last_speed_ =
speed;
149 if (should_trigger) {
153 this->last_speed_ = state->
speed;
TEMPLATABLE_VALUE(bool, oscillating) TEMPLATABLE_VALUE(int
bool state
The current on/off state of the fan.
FanTurnOffTrigger(Fan *state)
FanIsOffCondition(Fan *state)
virtual FanTraits get_traits()=0
void play(Ts... x) override
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.
void play(Ts... x) override
FanCall & set_speed(int speed)
Base class for all automation conditions.
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)
bool check(Ts... x) override
FanSpeedSetTrigger(Fan *state)
TurnOffAction(Fan *state)
virtual void play(Ts... x)=0
FanCall & set_direction(FanDirection direction)
CycleSpeedAction(Fan *state)
void play(Ts... x) override