mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 09:17:46 +01:00
commit
b9720d0715
4 changed files with 15 additions and 6 deletions
|
@ -179,7 +179,7 @@ bool CurrentBasedCover::is_closing_blocked_() const {
|
|||
if (this->close_obstacle_current_threshold_ == FLT_MAX) {
|
||||
return false;
|
||||
}
|
||||
return this->open_sensor_->get_state() > this->open_obstacle_current_threshold_;
|
||||
return this->close_sensor_->get_state() > this->close_obstacle_current_threshold_;
|
||||
}
|
||||
bool CurrentBasedCover::is_initial_delay_finished_() const {
|
||||
return millis() - this->start_dir_time_ > this->start_sensing_delay_;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <queue>
|
||||
namespace esphome {
|
||||
namespace script {
|
||||
|
||||
|
@ -88,7 +89,7 @@ template<typename... Ts> class RestartScript : public Script<Ts...> {
|
|||
template<typename... Ts> class QueueingScript : public Script<Ts...>, public Component {
|
||||
public:
|
||||
void execute(Ts... x) override {
|
||||
if (this->is_action_running()) {
|
||||
if (this->is_action_running() || this->num_runs_ > 0) {
|
||||
// num_runs_ is the number of *queued* instances, so total number of instances is
|
||||
// num_runs_ + 1
|
||||
if (this->max_runs_ != 0 && this->num_runs_ + 1 >= this->max_runs_) {
|
||||
|
@ -98,6 +99,7 @@ template<typename... Ts> class QueueingScript : public Script<Ts...>, public Com
|
|||
|
||||
this->esp_logd_(__LINE__, "Script '%s' queueing new instance (mode: queued)", this->name_.c_str());
|
||||
this->num_runs_++;
|
||||
this->var_queue_.push(std::make_tuple(x...));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -114,15 +116,22 @@ template<typename... Ts> class QueueingScript : public Script<Ts...>, public Com
|
|||
void loop() override {
|
||||
if (this->num_runs_ != 0 && !this->is_action_running()) {
|
||||
this->num_runs_--;
|
||||
this->trigger();
|
||||
auto &vars = this->var_queue_.front();
|
||||
this->var_queue_.pop();
|
||||
this->trigger_tuple_(vars, typename gens<sizeof...(Ts)>::type());
|
||||
}
|
||||
}
|
||||
|
||||
void set_max_runs(int max_runs) { max_runs_ = max_runs; }
|
||||
|
||||
protected:
|
||||
template<int... S> void trigger_tuple_(const std::tuple<Ts...> &tuple, seq<S...> /*unused*/) {
|
||||
this->trigger(std::get<S>(tuple)...);
|
||||
}
|
||||
|
||||
int num_runs_ = 0;
|
||||
int max_runs_ = 0;
|
||||
std::queue<std::tuple<Ts...>> var_queue_;
|
||||
};
|
||||
|
||||
/** A script type that executes new instances in parallel.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2022.11.3"
|
||||
__version__ = "2022.11.4"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
|
||||
|
|
|
@ -849,7 +849,7 @@ PING_REQUEST = threading.Event()
|
|||
class LoginHandler(BaseHandler):
|
||||
def get(self):
|
||||
if is_authenticated(self):
|
||||
self.redirect("/")
|
||||
self.redirect("./")
|
||||
else:
|
||||
self.render_login_page()
|
||||
|
||||
|
@ -894,7 +894,7 @@ class LoginHandler(BaseHandler):
|
|||
password = self.get_argument("password", "")
|
||||
if settings.check_password(username, password):
|
||||
self.set_secure_cookie("authenticated", cookie_authenticated_yes)
|
||||
self.redirect("/")
|
||||
self.redirect("./")
|
||||
return
|
||||
error_str = (
|
||||
"Invalid username or password" if settings.username else "Invalid password"
|
||||
|
|
Loading…
Reference in a new issue