ESPHome 2025.5.0
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 if (call.get_state().has_value())
22 this->state = *call.get_state();
23 if (call.get_oscillating().has_value())
24 this->oscillating = *call.get_oscillating();
25 if (call.get_direction().has_value())
26 this->direction = *call.get_direction();
27
28 this->write_state_();
29 this->publish_state();
30}
32 this->output_->set_state(this->state);
33 if (this->oscillating_ != nullptr)
35 if (this->direction_ != nullptr)
37}
38
39} // namespace binary
40} // 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_state() const
Definition fan.h:49
optional< bool > get_oscillating() const
Definition fan.h:58
optional< FanDirection > get_direction() const
Definition fan.h:74
void publish_state()
Definition fan.cpp:117
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:140
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