ESPHome 2026.2.1
Loading...
Searching...
No Matches
template_number.h
Go to the documentation of this file.
1#pragma once
2
8
9namespace esphome::template_ {
10
11class TemplateNumber final : public number::Number, public PollingComponent {
12 public:
13 template<typename F> void set_template(F &&f) { this->f_.set(std::forward<F>(f)); }
14
15 void setup() override;
16 void update() override;
17 void dump_config() override;
18 float get_setup_priority() const override { return setup_priority::HARDWARE; }
19
21 void set_optimistic(bool optimistic) { optimistic_ = optimistic; }
22 void set_initial_value(float initial_value) { initial_value_ = initial_value; }
23 void set_restore_value(bool restore_value) { this->restore_value_ = restore_value; }
24
25 protected:
26 void control(float value) override;
27 bool optimistic_{false};
28 float initial_value_{NAN};
29 bool restore_value_{false};
32
34};
35
36} // namespace esphome::template_
ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t std::function< RetryResult(uint8_t)> && f
Definition component.h:373
This class simplifies creating components that periodically check a state.
Definition component.h:512
Lightweight wrapper for template platform lambdas (stateless function pointers only).
void set(optional< T >(*f)(Args...))
Set the lambda function pointer.
Base-class for all numbers.
Definition number.h:29
void set_restore_value(bool restore_value)
float get_setup_priority() const override
void set_optimistic(bool optimistic)
void control(float value) override
void set_initial_value(float initial_value)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.cpp:83