ESPHome 2025.11.0b4
Loading...
Searching...
No Matches
template_switch.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome {
9namespace template_ {
10
11class TemplateSwitch final : public switch_::Switch, public Component {
12 public:
14
15 void setup() override;
16 void dump_config() override;
17
18 template<typename F> void set_state_lambda(F &&f) { this->f_.set(std::forward<F>(f)); }
21 void set_optimistic(bool optimistic);
23 void loop() override;
24
25 float get_setup_priority() const override;
26
27 protected:
28 bool assumed_state() override;
29
30 void write_state(bool state) override;
31
33 bool optimistic_{false};
34 bool assumed_state_{false};
38};
39
40} // namespace template_
41} // namespace esphome
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)
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7