2021-07-12 21:20:12 +02:00
|
|
|
#include "number.h"
|
|
|
|
#include "esphome/core/log.h"
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
namespace number {
|
|
|
|
|
|
|
|
static const char *const TAG = "number";
|
|
|
|
|
|
|
|
void Number::publish_state(float state) {
|
|
|
|
this->has_state_ = true;
|
|
|
|
this->state = state;
|
2021-07-19 22:22:49 +02:00
|
|
|
ESP_LOGD(TAG, "'%s': Sending state %f", this->get_name().c_str(), state);
|
2021-07-12 21:20:12 +02:00
|
|
|
this->state_callback_.call(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Number::add_on_state_callback(std::function<void(float)> &&callback) {
|
|
|
|
this->state_callback_.add(std::move(callback));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace number
|
|
|
|
} // namespace esphome
|