ESPHome 2026.1.0-dev
Loading...
Searching...
No Matches
template_switch.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome::template_ {
9
10class TemplateSwitch final : public switch_::Switch, public Component {
11 public:
13
14 void setup() override;
15 void dump_config() override;
16
17 template<typename F> void set_state_lambda(F &&f) { this->f_.set(std::forward<F>(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 esphome::template_
Lightweight wrapper for template platform lambdas (stateless function pointers only).
void set(optional< T >(*f)(Args...))
Set the lambda function pointer.
Base class for all switches.
Definition switch.h:39
bool state
The current reported state of the binary sensor.
Definition switch.h:56
float get_setup_priority() const override
void write_state(bool state) override
void set_assumed_state(bool assumed_state)