11static constexpr uint32_t ROLLBACK_TIMEOUT_ID = 0;
17 traits.set_supports_stop(
true);
18 traits.set_supports_position(
true);
19 traits.set_supports_toggle(
true);
20 traits.set_is_assumed_state(
false);
24 if (
call.get_stop()) {
41 auto opt_pos =
call.get_position();
42 if (opt_pos.has_value()) {
55 if (restore.has_value()) {
72 ESP_LOGI(TAG,
"'%s' - Malfunction detected during opening. Current flow detected in close circuit",
75 ESP_LOGD(TAG,
"'%s' - Obstacle detected during opening.", LOG_STR_ARG(this->
get_log_name()));
78 this->
set_timeout(ROLLBACK_TIMEOUT_ID, 300, [
this]() {
79 ESP_LOGD(TAG,
"'%s' - Rollback.", LOG_STR_ARG(this->
get_log_name()));
86 ESP_LOGD(TAG,
"'%s' - Open position reached. Took %.1fs.", LOG_STR_ARG(this->
get_log_name()), dur);
93 ESP_LOGI(TAG,
"'%s' - Malfunction detected during closing. Current flow detected in open circuit",
96 ESP_LOGD(TAG,
"'%s' - Obstacle detected during closing.", LOG_STR_ARG(this->
get_log_name()));
99 this->
set_timeout(ROLLBACK_TIMEOUT_ID, 300, [
this]() {
100 ESP_LOGD(TAG,
"'%s' - Rollback.", LOG_STR_ARG(this->
get_log_name()));
107 ESP_LOGD(TAG,
"'%s' - Close position reached. Took %.1fs.", LOG_STR_ARG(this->
get_log_name()), dur);
112 ESP_LOGD(TAG,
"'%s' - Max duration reached. Stopping cover.", LOG_STR_ARG(this->
get_log_name()));
132 if (new_position != FLT_MAX) {
139 LOG_COVER(
"",
"Endstop Cover",
this);
145 ESP_LOGCONFIG(TAG,
" Open Duration: %.1fs", this->
open_duration_ / 1e3f);
152 " Close Duration: %.1fs\n"
153 " Obstacle Rollback: %.1f%%",
156 ESP_LOGCONFIG(TAG,
" Maximum duration: %.1fs", this->
max_duration_ / 1e3f);
159 " Start sensing delay: %.1fs\n"
160 " Malfunction detection: %s",
245 const auto now =
millis();
268 const auto now =
millis();
270 this->
position = clamp(this->position, 0.0F, 1.0F);
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.
void set_timeout(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a const char* name.
const LogString * get_log_name() const
Get the name for a "%s" log argument (LOG_STR_ARG).
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.
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).
float close_moving_current_threshold_
sensor::Sensor * close_sensor_
void start_direction_(cover::CoverOperation dir)
float open_obstacle_current_threshold_
void recompute_position_()
bool is_closing_blocked_() const
Trigger * prev_command_trigger_
bool is_at_target_() const
uint32_t last_publish_time_
float open_moving_current_threshold_
float close_obstacle_current_threshold_
bool is_initial_delay_finished_() const
cover::CoverTraits get_traits() override
bool is_opening_blocked_() const
uint32_t start_sensing_delay_
void dump_config() override
void control(const cover::CoverCall &call) override
cover::CoverOperation last_operation_
bool malfunction_detection_
void stop_prev_trigger_()
Trigger malfunction_trigger_
uint32_t last_recompute_time_
void direction_idle_(float new_position=FLT_MAX)
sensor::Sensor * open_sensor_
float get_state() const
Getter-syntax for .state.
ESPHOME_LOG_TAG(TAG, "cover")
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)
uint32_t IRAM_ATTR HOT millis()
Application App
Global storage of Application pointer - only one Application can exist.