ESPHome  2024.11.0
template_valve.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace template_ {
9 
14 };
15 
16 class TemplateValve : public valve::Valve, public Component {
17  public:
18  TemplateValve();
19 
20  void set_state_lambda(std::function<optional<float>()> &&f);
21  Trigger<> *get_open_trigger() const;
23  Trigger<> *get_stop_trigger() const;
26  void set_optimistic(bool optimistic);
27  void set_assumed_state(bool assumed_state);
28  void set_has_stop(bool has_stop);
29  void set_has_position(bool has_position);
30  void set_has_toggle(bool has_toggle);
31  void set_restore_mode(TemplateValveRestoreMode restore_mode) { restore_mode_ = restore_mode; }
32 
33  void setup() override;
34  void loop() override;
35  void dump_config() override;
36 
37  float get_setup_priority() const override;
38 
39  protected:
40  void control(const valve::ValveCall &call) override;
41  valve::ValveTraits get_traits() override;
42  void stop_prev_trigger_();
43 
46  bool assumed_state_{false};
47  bool optimistic_{false};
50  bool has_stop_{false};
51  bool has_toggle_{false};
56  bool has_position_{false};
57 };
58 
59 } // namespace template_
60 } // namespace esphome
void set_has_position(bool has_position)
void set_has_toggle(bool has_toggle)
void set_state_lambda(std::function< optional< float >()> &&f)
void control(const valve::ValveCall &call) override
float get_setup_priority() const override
void set_optimistic(bool optimistic)
optional< std::function< optional< float >)> > state_f_
Trigger< float > * position_trigger_
void set_restore_mode(TemplateValveRestoreMode restore_mode)
Trigger< float > * get_position_trigger() const
valve::ValveTraits get_traits() override
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
Base class for all valve devices.
Definition: valve.h:105
TemplateValveRestoreMode restore_mode_
void set_assumed_state(bool assumed_state)