ESPHome  2022.8.0
output_switch.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace output {
9 
17 };
18 
19 class OutputSwitch : public switch_::Switch, public Component {
20  public:
21  void set_output(BinaryOutput *output) { output_ = output; }
22 
23  void set_restore_mode(OutputSwitchRestoreMode restore_mode) { restore_mode_ = restore_mode; }
24 
25  void setup() override;
26  float get_setup_priority() const override { return setup_priority::HARDWARE - 1.0f; }
27  void dump_config() override;
28 
29  protected:
30  void write_state(bool state) override;
31 
34 };
35 
36 } // namespace output
37 } // namespace esphome
Base class for all switches.
Definition: switch.h:33
output::BinaryOutput * output_
Definition: output_switch.h:32
void set_restore_mode(OutputSwitchRestoreMode restore_mode)
Definition: output_switch.h:23
void write_state(bool state) override
void set_output(BinaryOutput *output)
Definition: output_switch.h:21
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition: component.cpp:17
float get_setup_priority() const override
Definition: output_switch.h:26
OutputSwitchRestoreMode restore_mode_
Definition: output_switch.h:33
Definition: a4988.cpp:4
bool state
The current reported state of the binary sensor.
Definition: switch.h:48