9static const char *
const TAG =
"endstop.cover";
15 traits.set_supports_stop(
true);
16 traits.set_supports_position(
true);
17 traits.set_supports_toggle(
true);
18 traits.set_is_assumed_state(
false);
22 if (
call.get_stop()) {
41 auto pos = *
call.get_position();
53 if (restore.has_value()) {
61 }
else if (!restore.has_value()) {
73 ESP_LOGD(TAG,
"'%s' - Open endstop reached. Took %.1fs.", this->
name_.
c_str(), dur);
80 ESP_LOGD(TAG,
"'%s' - Close endstop reached. Took %.1fs.", this->
name_.
c_str(), dur);
86 ESP_LOGD(TAG,
"'%s' - Max duration reached. Stopping cover.", this->
name_.
c_str());
106 LOG_COVER(
"",
"Endstop Cover",
this);
108 ESP_LOGCONFIG(TAG,
" Open Duration: %.1fs", this->
open_duration_ / 1e3f);
110 ESP_LOGCONFIG(TAG,
" Close Duration: %.1fs", this->
close_duration_ / 1e3f);
162 const uint32_t now =
millis();
185 const uint32_t now =
millis();
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.
constexpr const char * c_str() const
void stop_action()
Stop any action connected to this trigger.
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
const optional< bool > & get_toggle() const
const optional< float > & get_position() 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).
binary_sensor::BinarySensor * open_endstop_
Trigger * prev_command_trigger_
cover::CoverTraits get_traits() override
void start_direction_(cover::CoverOperation dir)
uint32_t last_recompute_time_
void stop_prev_trigger_()
bool is_at_target_() const
void recompute_position_()
binary_sensor::BinarySensor * close_endstop_
void control(const cover::CoverCall &call) override
uint32_t last_publish_time_
void dump_config() override
float get_setup_priority() const override
cover::CoverOperation last_operation_
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)
const float DATA
For components that import data from directly connected sensors like DHT.
Providing packet encoding functions for exchanging data with a remote host.
uint32_t IRAM_ATTR HOT millis()
Application App
Global storage of Application pointer - only one Application can exist.
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)