ESPHome  2022.6.2
template_cover.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace template_ {
9 
14 };
15 
16 class TemplateCover : public cover::Cover, public Component {
17  public:
18  TemplateCover();
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_tilt_lambda(std::function<optional<float>()> &&tilt_f);
29  void set_has_position(bool has_position);
30  void set_has_tilt(bool has_tilt);
31  void set_restore_mode(TemplateCoverRestoreMode 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 cover::CoverCall &call) override;
41  cover::CoverTraits get_traits() override;
42  void stop_prev_trigger_();
43 
47  bool assumed_state_{false};
48  bool optimistic_{false};
54  bool has_position_{false};
56  bool has_tilt_{false};
57 };
58 
59 } // namespace template_
60 } // namespace esphome
float get_setup_priority() const override
Base class for all cover devices.
Definition: cover.h:111
void set_has_position(bool has_position)
Trigger< float > * position_trigger_
cover::CoverTraits get_traits() override
void set_tilt_lambda(std::function< optional< float >()> &&tilt_f)
void set_optimistic(bool optimistic)
void control(const cover::CoverCall &call) override
void set_restore_mode(TemplateCoverRestoreMode restore_mode)
void set_state_lambda(std::function< optional< float >()> &&f)
TemplateCoverRestoreMode restore_mode_
Trigger< float > * get_position_trigger() const
void set_assumed_state(bool assumed_state)
optional< std::function< optional< float >)> > state_f_
optional< std::function< optional< float >)> > tilt_f_
Trigger< float > * get_tilt_trigger() const
Definition: a4988.cpp:4