ESPHome
2026.6.0-dev
Loading...
Searching...
No Matches
esphome
components
copy
sensor
copy_sensor.cpp
Go to the documentation of this file.
1
#include "
copy_sensor.h
"
2
#include "
esphome/core/log.h
"
3
4
namespace
esphome::copy
{
5
6
static
const
char
*
const
TAG =
"copy.sensor"
;
7
8
void
CopySensor::setup
() {
9
source_
->
add_on_state_callback
([
this
](
float
value) { this->
publish_state
(value); });
10
if
(
source_
->
has_state
())
11
this->
publish_state
(
source_
->
state
);
12
}
13
14
void
CopySensor::dump_config
() { LOG_SENSOR(
""
,
"Copy Sensor"
,
this
); }
15
16
}
// namespace esphome::copy
esphome::EntityBase::has_state
bool has_state() const
Definition
entity_base.h:191
esphome::copy::CopySensor::source_
sensor::Sensor * source_
Definition
copy_sensor.h:15
esphome::copy::CopySensor::setup
void setup() override
Definition
copy_sensor.cpp:8
esphome::copy::CopySensor::dump_config
void dump_config() override
Definition
copy_sensor.cpp:14
esphome::sensor::Sensor::add_on_state_callback
void add_on_state_callback(F &&callback)
Add a callback that will be called every time a filtered value arrives.
Definition
sensor.h:119
esphome::sensor::Sensor::publish_state
void publish_state(float state)
Publish a new state to the front-end.
Definition
sensor.cpp:68
esphome::sensor::Sensor::state
float state
This member variable stores the last state that has passed through all filters.
Definition
sensor.h:138
copy_sensor.h
log.h
esphome::copy
Definition
copy_binary_sensor.cpp:4
Generated by
1.12.0