ESPHome 2026.4.0-dev
Loading...
Searching...
No Matches
number_sensor.cpp
Go to the documentation of this file.
1#include "number_sensor.h"
2#include "esphome/core/log.h"
3
4namespace esphome::number {
5
6static const char *const TAG = "number.sensor";
7
9 this->source_->add_on_state_callback([this](float value) { this->publish_state(value); });
10 if (this->source_->has_state())
11 this->publish_state(this->source_->state);
12}
13
14void NumberSensor::dump_config() { LOG_SENSOR("", "Number Sensor", this); }
15
16} // namespace esphome::number
bool has_state() const
void add_on_state_callback(F &&callback)
Definition number.h:37
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68