ESPHome 2026.6.0-dev
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::copy {
5
6static const char *const TAG = "copy.sensor";
7
9 source_->add_on_state_callback([this](float value) { this->publish_state(value); });
10 if (source_->has_state())
12}
13
14void CopySensor::dump_config() { LOG_SENSOR("", "Copy Sensor", this); }
15
16} // namespace esphome::copy
bool has_state() const
sensor::Sensor * source_
Definition copy_sensor.h:15
void dump_config() override
void add_on_state_callback(F &&callback)
Add a callback that will be called every time a filtered value arrives.
Definition sensor.h:119
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68
float state
This member variable stores the last state that has passed through all filters.
Definition sensor.h:138