ESPHome 2026.2.4
Loading...
Searching...
No Matches
endstop_cover.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome {
9namespace endstop {
10
11class EndstopCover : public cover::Cover, public Component {
12 public:
13 void setup() override;
14 void loop() override;
15 void dump_config() override;
16
20 void set_open_endstop(binary_sensor::BinarySensor *open_endstop) { this->open_endstop_ = open_endstop; }
21 void set_close_endstop(binary_sensor::BinarySensor *close_endstop) { this->close_endstop_ = close_endstop; }
22 void set_open_duration(uint32_t open_duration) { this->open_duration_ = open_duration; }
23 void set_close_duration(uint32_t close_duration) { this->close_duration_ = close_duration; }
24 void set_max_duration(uint32_t max_duration) { this->max_duration_ = max_duration; }
25
27
28 protected:
29 void control(const cover::CoverCall &call) override;
30 void stop_prev_trigger_();
31 bool is_open_() const { return this->open_endstop_->state; }
32 bool is_closed_() const { return this->close_endstop_->state; }
33 bool is_at_target_() const;
34
36
38
46 uint32_t max_duration_{UINT32_MAX};
47
50 uint32_t start_dir_time_{0};
51 uint32_t last_publish_time_{0};
54};
55
56} // namespace endstop
57} // namespace esphome
Base class for all binary_sensor-type classes.
Base class for all cover devices.
Definition cover.h:110
binary_sensor::BinarySensor * open_endstop_
cover::CoverTraits get_traits() override
void start_direction_(cover::CoverOperation dir)
void set_max_duration(uint32_t max_duration)
void set_close_endstop(binary_sensor::BinarySensor *close_endstop)
void set_open_endstop(binary_sensor::BinarySensor *open_endstop)
binary_sensor::BinarySensor * close_endstop_
void set_open_duration(uint32_t open_duration)
void set_close_duration(uint32_t close_duration)
void control(const cover::CoverCall &call) override
cover::CoverOperation last_operation_
CoverOperation
Enum encoding the current operation of a cover.
Definition cover.h:79
@ COVER_OPERATION_OPENING
The cover is currently opening.
Definition cover.h:83
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7