8static const char *
const TAG =
"feedback.cover";
10static constexpr uint32_t DIRECTION_CHANGE_TIMEOUT_ID = 1;
17 if (restore.has_value()) {
25#ifdef USE_BINARY_SENSOR
46 traits.set_supports_stop(
true);
47 traits.set_supports_position(
true);
48 traits.set_supports_toggle(
true);
54 LOG_COVER(
"",
"Endstop Cover",
this);
55 ESP_LOGCONFIG(TAG,
" Open Duration: %.1fs", this->
open_duration_ / 1e3f);
56#ifdef USE_BINARY_SENSOR
61 ESP_LOGCONFIG(TAG,
" Close Duration: %.1fs", this->
close_duration_ / 1e3f);
62#ifdef USE_BINARY_SENSOR
68 ESP_LOGCONFIG(TAG,
" Has builtin endstop: YES");
71 ESP_LOGCONFIG(TAG,
" Infer endstop from movement: YES");
74 ESP_LOGCONFIG(TAG,
" Max Duration: %.1fs", this->
max_duration_ / 1e3f);
82#ifdef USE_BINARY_SENSOR
89#ifdef USE_BINARY_SENSOR
96 ESP_LOGD(TAG,
"'%s' - Open feedback '%s'.", this->
name_.
c_str(), state ?
"STARTED" :
"ENDED");
109 ESP_LOGD(TAG,
"'%s' - Close feedback '%s'.", this->
name_.
c_str(), state ?
"STARTED" :
"ENDED");
141 this->
position = open_endstop ? COVER_OPEN : COVER_CLOSED;
147 ESP_LOGD(TAG,
"'%s' - %s endstop reached. Took %.1fs.", this->
name_.
c_str(), open_endstop ?
"Open" :
"Close", dur);
174#ifdef USE_BINARY_SENSOR
186#ifdef USE_BINARY_SENSOR
193 ESP_LOGD(TAG,
"'%s' - Close obstacle detected.", this->
name_.
c_str());
210 ESP_LOGD(TAG,
"'%s' - Open obstacle detected.", this->
name_.
c_str());
242 ESP_LOGD(TAG,
"'%s' - Max duration reached. Stopping cover.", this->
name_.
c_str());
258 if (
call.get_stop()) {
274 auto pos_opt =
call.get_position();
275 if (!pos_opt.has_value())
285#ifdef USE_BINARY_SENSOR
290#ifdef USE_BINARY_SENSOR
336#ifdef USE_BINARY_SENSOR
347#ifdef USE_BINARY_SENSOR
354#ifdef USE_BINARY_SENSOR
364#ifdef USE_BINARY_SENSOR
367 if (obstacle !=
nullptr && obstacle->state) {
368 ESP_LOGD(TAG,
"'%s' - %s obstacle detected. Action not started.", this->
name_.
c_str(),
379 ESP_LOGD(TAG,
"'%s' - Reversing direction.", this->
name_.
c_str());
385 ESP_LOGD(TAG,
"'%s' - Firing '%s' trigger.", this->
name_.
c_str(),
411 min_pos = COVER_CLOSED;
413#ifdef USE_BINARY_SENSOR
425#ifdef USE_BINARY_SENSOR
432 max_pos = COVER_OPEN;
443 effective_start = accel_end_time;
447 this->
position += dir * (now - effective_start) / (action_dur - this->acceleration_wait_time_);
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_timeout(const std voi set_timeout)(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_timeout(const std boo cancel_timeout)(const char *name)
Cancel a timeout function.
void add_on_state_callback(F &&callback)
constexpr const char * c_str() const
void stop_action()
Stop any action connected to this trigger.
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Inform the parent automation that the event has triggered.
Base class for all binary_sensor-type classes.
bool state
The current state of this binary sensor. Also used as the backing storage for StatefulEntityBase.
const optional< bool > & get_toggle() const
CoverOperation current_operation
The current operation of the cover (idle, opening, closing).
optional< CoverRestoreState > restore_state_()
void publish_state(bool save=true)
Publish the current state of the cover.
float position
The position of the cover from 0.0 (fully closed) to 1.0 (fully open).
cover::CoverTraits get_traits() override
cover::CoverOperation current_trigger_operation_
Trigger * prev_command_trigger_
binary_sensor::BinarySensor * open_endstop_
void start_direction_(cover::CoverOperation dir)
uint32_t update_interval_
void set_open_obstacle_sensor(binary_sensor::BinarySensor *open_obstacle)
void set_open_sensor(binary_sensor::BinarySensor *open_feedback)
void set_current_operation_(cover::CoverOperation operation, bool is_triggered)
binary_sensor::BinarySensor * close_endstop_
void set_close_endstop(binary_sensor::BinarySensor *close_endstop)
void stop_prev_trigger_()
optional< uint32_t > direction_change_waittime_
binary_sensor::BinarySensor * close_obstacle_
void set_close_obstacle_sensor(binary_sensor::BinarySensor *close_obstacle)
void control(const cover::CoverCall &call) override
binary_sensor::BinarySensor * open_feedback_
bool is_at_target_() const
bool has_built_in_endstop_
void dump_config() override
uint32_t acceleration_wait_time_
void recompute_position_()
void endstop_reached_(bool open_endstop)
void set_open_endstop(binary_sensor::BinarySensor *open_endstop)
cover::CoverOperation last_operation_
binary_sensor::BinarySensor * open_obstacle_
uint32_t last_recompute_time_
binary_sensor::BinarySensor * close_feedback_
uint32_t last_publish_time_
void set_close_sensor(binary_sensor::BinarySensor *close_feedback)
CoverOperation
Enum encoding the current operation of a cover.
@ COVER_OPERATION_OPENING
The cover is currently opening.
@ COVER_OPERATION_CLOSING
The cover is currently closing.
@ COVER_OPERATION_IDLE
The cover is currently idle (not moving)
Application App
Global storage of Application pointer - only one Application can exist.