mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 08:55:36 +00:00
Merge remote-tracking branch 'upstream-ssh/feedback-cover-loop-component-start-time' into integration
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/application.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace feedback {
|
||||
namespace esphome::feedback {
|
||||
|
||||
static const char *const TAG = "feedback.cover";
|
||||
|
||||
static constexpr uint32_t DIRECTION_CHANGE_TIMEOUT_ID = 1;
|
||||
|
||||
using namespace esphome::cover;
|
||||
|
||||
void FeedbackCover::setup() {
|
||||
@@ -37,7 +38,7 @@ void FeedbackCover::setup() {
|
||||
}
|
||||
#endif
|
||||
|
||||
this->last_recompute_time_ = this->start_dir_time_ = millis();
|
||||
this->last_recompute_time_ = this->start_dir_time_ = App.get_loop_component_start_time();
|
||||
}
|
||||
|
||||
CoverTraits FeedbackCover::get_traits() {
|
||||
@@ -135,7 +136,7 @@ void FeedbackCover::set_close_endstop(binary_sensor::BinarySensor *close_endstop
|
||||
#endif
|
||||
|
||||
void FeedbackCover::endstop_reached_(bool open_endstop) {
|
||||
const uint32_t now = millis();
|
||||
const uint32_t now = App.get_loop_component_start_time();
|
||||
|
||||
this->position = open_endstop ? COVER_OPEN : COVER_CLOSED;
|
||||
|
||||
@@ -174,7 +175,7 @@ void FeedbackCover::set_current_operation_(cover::CoverOperation operation, bool
|
||||
if (!is_triggered || (this->open_feedback_ == nullptr || this->close_feedback_ == nullptr))
|
||||
#endif
|
||||
{
|
||||
auto now = millis();
|
||||
const uint32_t now = App.get_loop_component_start_time();
|
||||
this->current_operation = operation;
|
||||
this->start_dir_time_ = this->last_recompute_time_ = now;
|
||||
this->publish_state();
|
||||
@@ -306,7 +307,7 @@ void FeedbackCover::control(const CoverCall &call) {
|
||||
|
||||
void FeedbackCover::stop_prev_trigger_() {
|
||||
if (this->direction_change_waittime_.has_value()) {
|
||||
this->cancel_timeout("direction_change");
|
||||
this->cancel_timeout(DIRECTION_CHANGE_TIMEOUT_ID);
|
||||
}
|
||||
if (this->prev_command_trigger_ != nullptr) {
|
||||
this->prev_command_trigger_->stop_action();
|
||||
@@ -377,7 +378,7 @@ void FeedbackCover::start_direction_(CoverOperation dir) {
|
||||
ESP_LOGD(TAG, "'%s' - Reversing direction.", this->name_.c_str());
|
||||
this->start_direction_(COVER_OPERATION_IDLE);
|
||||
|
||||
this->set_timeout("direction_change", *this->direction_change_waittime_,
|
||||
this->set_timeout(DIRECTION_CHANGE_TIMEOUT_ID, *this->direction_change_waittime_,
|
||||
[this, dir]() { this->start_direction_(dir); });
|
||||
|
||||
} else {
|
||||
@@ -395,7 +396,7 @@ void FeedbackCover::recompute_position_() {
|
||||
if (this->current_operation == COVER_OPERATION_IDLE)
|
||||
return;
|
||||
|
||||
const uint32_t now = millis();
|
||||
const uint32_t now = App.get_loop_component_start_time();
|
||||
float dir;
|
||||
float action_dur;
|
||||
float min_pos;
|
||||
@@ -451,5 +452,4 @@ void FeedbackCover::recompute_position_() {
|
||||
this->last_recompute_time_ = now;
|
||||
}
|
||||
|
||||
} // namespace feedback
|
||||
} // namespace esphome
|
||||
} // namespace esphome::feedback
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
#endif
|
||||
#include "esphome/components/cover/cover.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace feedback {
|
||||
namespace esphome::feedback {
|
||||
|
||||
class FeedbackCover : public cover::Cover, public Component {
|
||||
public:
|
||||
@@ -85,5 +84,4 @@ class FeedbackCover : public cover::Cover, public Component {
|
||||
uint32_t update_interval_{1000};
|
||||
};
|
||||
|
||||
} // namespace feedback
|
||||
} // namespace esphome
|
||||
} // namespace esphome::feedback
|
||||
|
||||
Reference in New Issue
Block a user