ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
binary_fan.cpp
Go to the documentation of this file.
1#include "binary_fan.h"
2#include "esphome/core/log.h"
3
4namespace esphome::binary {
5
6static const char *const TAG = "binary.fan";
7
9 auto restore = this->restore_state_();
10 if (restore.has_value()) {
11 restore->apply(*this);
12 this->write_state_();
13 }
14}
15void BinaryFan::dump_config() { LOG_FAN("", "Binary Fan", this); }
17 return fan::FanTraits(this->oscillating_ != nullptr, false, this->direction_ != nullptr, 0);
18}
20 auto state = call.get_state();
21 if (state.has_value())
22 this->state = *state;
23 auto oscillating = call.get_oscillating();
24 if (oscillating.has_value())
25 this->oscillating = *oscillating;
26 auto direction = call.get_direction();
27 if (direction.has_value())
28 this->direction = *direction;
29
30 this->write_state_();
31 this->publish_state();
32}
34 this->output_->set_state(this->state);
35 if (this->oscillating_ != nullptr)
37 if (this->direction_ != nullptr)
39}
40
41} // namespace esphome::binary
fan::FanTraits get_traits() override
output::BinaryOutput * oscillating_
Definition binary_fan.h:25
output::BinaryOutput * output_
Definition binary_fan.h:24
output::BinaryOutput * direction_
Definition binary_fan.h:26
void control(const fan::FanCall &call) override
void dump_config() override
optional< bool > get_oscillating() const
Definition fan.h:58
optional< FanDirection > get_direction() const
Definition fan.h:72
void publish_state()
Definition fan.cpp:223
FanDirection direction
The current direction of the fan.
Definition fan.h:116
bool oscillating
The current oscillation state of the fan.
Definition fan.h:112
bool state
The current on/off state of the fan.
Definition fan.h:110
optional< FanRestoreState > restore_state_()
Definition fan.cpp:251
virtual void set_state(bool state)
Enable or disable this binary output.