ESPHome 2025.5.0
Loading...
Searching...
No Matches
copy_sensor.cpp
Go to the documentation of this file.
1#include "copy_sensor.h"
2#include "esphome/core/log.h"
3
4namespace esphome {
5namespace copy {
6
7static const char *const TAG = "copy.sensor";
8
10 source_->add_on_state_callback([this](float value) { this->publish_state(value); });
11 if (source_->has_state())
13}
14
15void CopySensor::dump_config() { LOG_SENSOR("", "Copy Sensor", this); }
16
17} // namespace copy
18} // namespace esphome
sensor::Sensor * source_
Definition copy_sensor.h:17
void dump_config() override
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:39
void add_on_state_callback(std::function< void(float)> &&callback)
Add a callback that will be called every time a filtered value arrives.
Definition sensor.cpp:52
bool has_state() const
Return whether this sensor has gotten a full state (that passed through all filters) yet.
Definition sensor.cpp:97
float state
This member variable stores the last state that has passed through all filters.
Definition sensor.h:131
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7