ESPHome  2024.11.0
number.cpp
Go to the documentation of this file.
1 #include "number.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace number {
6 
7 static const char *const TAG = "number";
8 
10  this->has_state_ = true;
11  this->state = state;
12  ESP_LOGD(TAG, "'%s': Sending state %f", this->get_name().c_str(), state);
13  this->state_callback_.call(state);
14 }
15 
16 void Number::add_on_state_callback(std::function<void(float)> &&callback) {
17  this->state_callback_.add(std::move(callback));
18 }
19 
20 } // namespace number
21 } // namespace esphome
void add_on_state_callback(std::function< void(float)> &&callback)
Definition: number.cpp:16
void publish_state(float state)
Definition: number.cpp:9
CallbackManager< void(float)> state_callback_
Definition: number.h:65
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
const StringRef & get_name() const
Definition: entity_base.cpp:10
bool state
Definition: fan.h:34