ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
template_sensor.cpp
Go to the documentation of this file.
1#include "template_sensor.h"
2#include "esphome/core/log.h"
3#include <cmath>
4
5namespace esphome {
6namespace template_ {
7
8static const char *const TAG = "template.sensor";
9
11 if (!this->f_.has_value())
12 return;
13
14 auto val = this->f_();
15 if (val.has_value()) {
16 this->publish_state(*val);
17 }
18}
19
21
23 LOG_SENSOR("", "Template Sensor", this);
24 LOG_UPDATE_INTERVAL(this);
25}
26
27} // namespace template_
28} // namespace esphome
bool has_value() const
Check if a lambda is set.
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:75
float get_setup_priority() const override
mopeka_std_values val[4]
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.cpp:58
const char *const TAG
Definition spi.cpp:8
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7