ESPHome  2024.12.2
copy_number.cpp
Go to the documentation of this file.
1 #include "copy_number.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace copy {
6 
7 static const char *const TAG = "copy.number";
8 
10  source_->add_on_state_callback([this](float value) { this->publish_state(value); });
11 
15 
16  if (source_->has_state())
17  this->publish_state(source_->state);
18 }
19 
20 void CopyNumber::dump_config() { LOG_NUMBER("", "Copy Number", this); }
21 
22 void CopyNumber::control(float value) {
23  auto call2 = source_->make_call();
24  call2.set_value(value);
25  call2.perform();
26 }
27 
28 } // namespace copy
29 } // namespace esphome
bool has_state() const
Return whether this number has gotten a full state yet.
Definition: number.h:52
void add_on_state_callback(std::function< void(float)> &&callback)
Definition: number.cpp:16
void publish_state(float state)
Definition: number.cpp:9
NumberCall & set_value(float value)
Definition: number_call.cpp:10
void setup() override
Definition: copy_number.cpp:9
void set_min_value(float min_value)
Definition: number_traits.h:18
void control(float value) override
Definition: copy_number.cpp:22
void set_max_value(float max_value)
Definition: number_traits.h:20
NumberTraits traits
Definition: number.h:49
number::Number * source_
Definition: copy_number.h:19
NumberCall make_call()
Definition: number.h:45
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void dump_config() override
Definition: copy_number.cpp:20