ESPHome  2024.10.2
time_based_cover.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace time_based {
9 
10 class TimeBasedCover : public cover::Cover, public Component {
11  public:
12  void setup() override;
13  void loop() override;
14  void dump_config() override;
15  float get_setup_priority() const override;
16 
17  Trigger<> *get_open_trigger() const { return this->open_trigger_; }
18  Trigger<> *get_close_trigger() const { return this->close_trigger_; }
19  Trigger<> *get_stop_trigger() const { return this->stop_trigger_; }
20  void set_open_duration(uint32_t open_duration) { this->open_duration_ = open_duration; }
21  void set_close_duration(uint32_t close_duration) { this->close_duration_ = close_duration; }
22  cover::CoverTraits get_traits() override;
23  void set_has_built_in_endstop(bool value) { this->has_built_in_endstop_ = value; }
24  void set_manual_control(bool value) { this->manual_control_ = value; }
25  void set_assumed_state(bool value) { this->assumed_state_ = value; }
27 
28  protected:
29  void control(const cover::CoverCall &call) override;
30  void stop_prev_trigger_();
31  bool is_at_target_() const;
32 
34 
35  void recompute_position_();
36 
38  uint32_t open_duration_;
40  uint32_t close_duration_;
42 
44  uint32_t last_recompute_time_{0};
45  uint32_t start_dir_time_{0};
46  uint32_t last_publish_time_{0};
47  float target_position_{0};
48  bool has_built_in_endstop_{false};
49  bool manual_control_{false};
50  bool assumed_state_{false};
52 };
53 
54 } // namespace time_based
55 } // namespace esphome
void control(const cover::CoverCall &call) override
Base class for all cover devices.
Definition: cover.h:111
CoverOperation
Enum encoding the current operation of a cover.
Definition: cover.h:80
cover::CoverTraits get_traits() override
float get_setup_priority() const override
cover::CoverOperation last_operation_
void start_direction_(cover::CoverOperation dir)
cover::CoverOperation get_last_operation() const
void set_close_duration(uint32_t close_duration)
void set_open_duration(uint32_t open_duration)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
The cover is currently opening.
Definition: cover.h:84