mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-07 05:13:31 +02:00
Number and Template Number updates (#2036)
Co-authored-by: Otto winter <otto@otto-winter.com>
This commit is contained in:
@@ -3,27 +3,32 @@
|
||||
#include "esphome/components/number/number.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/preferences.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace template_ {
|
||||
|
||||
class TemplateNumber : public number::Number, public PollingComponent {
|
||||
public:
|
||||
TemplateNumber();
|
||||
void set_template(std::function<optional<float>()> &&f);
|
||||
void set_template(std::function<optional<float>()> &&f) { this->f_ = f; }
|
||||
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
float get_setup_priority() const override;
|
||||
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
||||
|
||||
Trigger<float> *get_set_trigger() const;
|
||||
void set_optimistic(bool optimistic);
|
||||
Trigger<float> *get_set_trigger() const { return set_trigger_; }
|
||||
void set_optimistic(bool optimistic) { optimistic_ = optimistic; }
|
||||
void set_initial_value(float initial_value) { initial_value_ = initial_value; }
|
||||
|
||||
protected:
|
||||
void set(float value) override;
|
||||
void control(float value) override;
|
||||
bool optimistic_{false};
|
||||
Trigger<float> *set_trigger_;
|
||||
float initial_value_{NAN};
|
||||
Trigger<float> *set_trigger_ = new Trigger<float>();
|
||||
optional<std::function<optional<float>()>> f_;
|
||||
|
||||
ESPPreferenceObject pref_;
|
||||
};
|
||||
|
||||
} // namespace template_
|
||||
|
||||
Reference in New Issue
Block a user