ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
template_sensor.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::template_ {
8
9class TemplateSensor final : public sensor::Sensor, public PollingComponent {
10 public:
11 // User provided, not "= default": `new(p) TemplateSensor()` would zero-fill .bss that is already zero.
13 template<typename F> void set_template(F &&f) { this->f_.set(std::forward<F>(f)); }
14
15 void update() override;
16
17 void dump_config() override;
18
19 float get_setup_priority() const override;
20
21 protected:
23};
24
25} // namespace esphome::template_
This class simplifies creating components that periodically check a state.
Definition component.h:519
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 sensors.
Definition sensor.h:47
float get_setup_priority() const override