6static const char *
const TAG =
"binary_sensor.automation";
25 ESP_LOGV(TAG,
"Multi Click: Starting multi click action!");
34 ESP_LOGV(TAG,
"Multi Click: action not started because first level does not match!");
70 ESP_LOGV(TAG,
"Multi Click: Invalid length of press, starting cooldown of %" PRIu32
" ms", this->
invalid_cooldown_);
73 ESP_LOGV(TAG,
"Multi Click: Cooldown ended, matching is now enabled again.");
82 if (min_length == 0) {
87 this->
set_timeout(
"is_valid", min_length, [
this]() {
88 ESP_LOGV(TAG,
"Multi Click: You can now %s the button.", this->
parent_->
state ?
"RELEASE" :
"PRESS");
93 this->
set_timeout(
"is_not_valid", max_length, [
this]() {
94 ESP_LOGV(TAG,
"Multi Click: You waited too long to %s.", this->
parent_->
state ?
"RELEASE" :
"PRESS");
100 ESP_LOGV(TAG,
"Multi Click: Sequence explicitly cancelled.");
105 ESP_LOGV(TAG,
"Multi Click: Hooray, multi click is valid. Triggering!");
114 if (max_length == 0) {
115 return length >= min_length;
bool cancel_timeout(const std::string &name)
Cancel a timeout function.
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
void trigger(const Ts &...x)
void on_state_(bool state)
FixedVector< MultiClickTriggerEvent > timing_
void schedule_is_not_valid_(uint32_t max_length)
uint32_t invalid_cooldown_
void schedule_is_valid_(uint32_t min_length)
optional< size_t > at_index_
void schedule_cooldown_()
bool match_interval(uint32_t min_length, uint32_t max_length, uint32_t length)