ESPHome 2025.5.0
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 float get_setup_priority() const override;
17
18 Trigger<> *get_open_trigger() const { return this->open_trigger_; }
19 Trigger<> *get_close_trigger() const { return this->close_trigger_; }
20 Trigger<> *get_stop_trigger() const { return this->stop_trigger_; }
21 void set_open_endstop(binary_sensor::BinarySensor *open_endstop) { this->open_endstop_ = open_endstop; }
22 void set_close_endstop(binary_sensor::BinarySensor *close_endstop) { this->close_endstop_ = close_endstop; }
23 void set_open_duration(uint32_t open_duration) { this->open_duration_ = open_duration; }
24 void set_close_duration(uint32_t close_duration) { this->close_duration_ = close_duration; }
25 void set_max_duration(uint32_t max_duration) { this->max_duration_ = max_duration; }
26
28
29 protected:
30 void control(const cover::CoverCall &call) override;
31 void stop_prev_trigger_();
32 bool is_open_() const { return this->open_endstop_->state; }
33 bool is_closed_() const { return this->close_endstop_->state; }
34 bool is_at_target_() const;
35
37
39
47 uint32_t max_duration_{UINT32_MAX};
48
51 uint32_t start_dir_time_{0};
52 uint32_t last_publish_time_{0};
55};
56
57} // namespace endstop
58} // namespace esphome
Base class for all binary_sensor-type classes.
bool state
The current reported state of the binary sensor.
Base class for all cover devices.
Definition cover.h:111
binary_sensor::BinarySensor * open_endstop_
cover::CoverTraits get_traits() override
Trigger * get_close_trigger() const
Trigger * get_stop_trigger() const
Trigger * get_open_trigger() const
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
float get_setup_priority() const override
cover::CoverOperation last_operation_
CoverOperation
Enum encoding the current operation of a cover.
Definition cover.h:80
@ COVER_OPERATION_OPENING
The cover is currently opening.
Definition cover.h:84
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7