ESPHome 2026.1.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::template_ {
6
7static const char *const TAG = "template.sensor";
8
10 if (!this->f_.has_value())
11 return;
12
13 auto val = this->f_();
14 if (val.has_value()) {
15 this->publish_state(*val);
16 }
17}
18
20
22 LOG_SENSOR("", "Template Sensor", this);
23 LOG_UPDATE_INTERVAL(this);
24}
25
26} // namespace esphome::template_
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:77
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:80
const char *const TAG
Definition spi.cpp:7