ESPHome  2024.10.2
template_switch.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace template_ {
9 
10 class TemplateSwitch : public switch_::Switch, public Component {
11  public:
13 
14  void setup() override;
15  void dump_config() override;
16 
17  void set_state_lambda(std::function<optional<bool>()> &&f);
20  void set_optimistic(bool optimistic);
22  void loop() override;
23 
24  float get_setup_priority() const override;
25 
26  protected:
27  bool assumed_state() override;
28 
29  void write_state(bool state) override;
30 
32  bool optimistic_{false};
33  bool assumed_state_{false};
37 };
38 
39 } // namespace template_
40 } // namespace esphome
Base class for all switches.
Definition: switch.h:39
void set_state_lambda(std::function< optional< bool >()> &&f)
void set_optimistic(bool optimistic)
void write_state(bool state) override
optional< std::function< optional< bool >)> > f_
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_assumed_state(bool assumed_state)
float get_setup_priority() const override
bool state
The current reported state of the binary sensor.
Definition: switch.h:53