ESPHome 2026.5.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 {
5namespace binary {
6
7static const char *const TAG = "binary.fan";
8
10 auto restore = this->restore_state_();
11 if (restore.has_value()) {
12 restore->apply(*this);
13 this->write_state_();
14 }
15}
16void BinaryFan::dump_config() { LOG_FAN("", "Binary Fan", this); }
18 return fan::FanTraits(this->oscillating_ != nullptr, false, this->direction_ != nullptr, 0);
19}
21 auto state = call.get_state();
22 if (state.has_value())
23 this->state = *state;
24 auto oscillating = call.get_oscillating();
25 if (oscillating.has_value())
26 this->oscillating = *oscillating;
27 auto direction = call.get_direction();
28 if (direction.has_value())
29 this->direction = *direction;
30
31 this->write_state_();
32 this->publish_state();
33}
35 this->output_->set_state(this->state);
36 if (this->oscillating_ != nullptr)
38 if (this->direction_ != nullptr)
40}
41
42} // namespace binary
43} // namespace esphome
fan::FanTraits get_traits() override
output::BinaryOutput * oscillating_
Definition binary_fan.h:26
output::BinaryOutput * output_
Definition binary_fan.h:25
output::BinaryOutput * direction_
Definition binary_fan.h:27
void control(const fan::FanCall &call) override
void dump_config() override
optional< bool > get_oscillating() const
Definition fan.h:59
optional< FanDirection > get_direction() const
Definition fan.h:73
void publish_state()
Definition fan.cpp:224
FanDirection direction
The current direction of the fan.
Definition fan.h:117
bool oscillating
The current oscillation state of the fan.
Definition fan.h:113
bool state
The current on/off state of the fan.
Definition fan.h:111
optional< FanRestoreState > restore_state_()
Definition fan.cpp:252
virtual void set_state(bool state)
Enable or disable this binary output.
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7