Add restore_value to template number (#2041)

This commit is contained in:
Jesse Hills
2021-07-20 15:40:42 +12:00
parent 53a4689ed1
commit c7a52c3894
3 changed files with 39 additions and 16 deletions
@@ -20,11 +20,13 @@ class TemplateNumber : public number::Number, public PollingComponent {
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; }
void set_restore_value(bool restore_value) { this->restore_value_ = restore_value; }
protected:
void control(float value) override;
bool optimistic_{false};
float initial_value_{NAN};
bool restore_value_{false};
Trigger<float> *set_trigger_ = new Trigger<float>();
optional<std::function<optional<float>()>> f_;