13#ifdef USE_STORE_LOG_STR_IN_FLASH
14 void esp_logw_(
int line,
const __FlashStringHelper *format,
const char *param) {
15 esp_log_(ESPHOME_LOG_LEVEL_WARN, line, format, param);
17 void esp_logd_(
int line,
const __FlashStringHelper *format,
const char *param) {
18 esp_log_(ESPHOME_LOG_LEVEL_DEBUG, line, format, param);
20 void esp_log_(
int level,
int line,
const __FlashStringHelper *format,
const char *param);
22 void esp_logw_(
int line,
const char *format,
const char *param) {
23 esp_log_(ESPHOME_LOG_LEVEL_WARN, line, format, param);
25 void esp_logd_(
int line,
const char *format,
const char *param) {
26 esp_log_(ESPHOME_LOG_LEVEL_DEBUG, line, format, param);
28 void esp_log_(
int level,
int line,
const char *format,
const char *param);
55 this->
execute(std::get<S>(tuple)...);
58 const LogString *
name_{
nullptr};
70 this->
esp_logw_(__LINE__, ESPHOME_LOG_FORMAT(
"Script '%s' is already running! (mode: single)"),
71 LOG_STR_ARG(this->
name_));
88 this->
esp_logd_(__LINE__, ESPHOME_LOG_FORMAT(
"Script '%s' restarting (mode: restart)"), LOG_STR_ARG(this->
name_));
107 this->
esp_logw_(__LINE__, ESPHOME_LOG_FORMAT(
"Script '%s' maximum number of queued runs exceeded!"),
108 LOG_STR_ARG(this->
name_));
112 this->
esp_logd_(__LINE__, ESPHOME_LOG_FORMAT(
"Script '%s' queueing new instance (mode: queued)"),
113 LOG_STR_ARG(this->
name_));
142 this->
trigger(std::get<S>(tuple)...);
159 this->
esp_logw_(__LINE__, ESPHOME_LOG_FORMAT(
"Script '%s' maximum number of parallel runs exceeded!"),
160 LOG_STR_ARG(this->
name_));
181 void play(Ts...
x)
override { this->script_->execute_tuple(this->eval_args_(
x...)); }
189 template<std::
size_t N>
191 std::integral_constant<std::size_t, N> , Ts... ) {}
193 template<std::
size_t I, std::
size_t N>
194 void eval_args_impl_(std::tuple<As...> &evaled_args, std::integral_constant<std::size_t, I> ,
195 std::integral_constant<std::size_t, N> n, Ts...
x) {
196 std::get<I>(evaled_args) = std::get<I>(args_).value(
x...);
197 eval_args_impl_(evaled_args, std::integral_constant<std::size_t, I + 1>{}, n,
202 std::tuple<As...> evaled_args;
203 eval_args_impl_(evaled_args, std::integral_constant<std::size_t, 0>{}, std::tuple_size<Args>{},
x...);
238 if (!this->
script_->is_running()) {
242 this->
var_ = std::make_tuple(
x...);
250 if (this->
script_->is_running())
void play_next_tuple_(const std::tuple< Ts... > &tuple, seq< S... >)
int num_running()
Return the number of actions in the action part of this automation that are currently running.
Base class for all automation conditions.
Automation< Ts... > * automation_parent_
bool check(Ts... x) override
IsRunningCondition(C *parent)
A script type that executes new instances in parallel.
void execute(Ts... x) override
void set_max_runs(int max_runs)
A script type that queues new instances that are created.
void trigger_tuple_(const std::tuple< Ts... > &tuple, seq< S... >)
void execute(Ts... x) override
std::queue< std::tuple< Ts... > > var_queue_
void set_max_runs(int max_runs)
A script type that restarts scripts from the beginning when a new instance is started.
void execute(Ts... x) override
Script< As... > * script_
void eval_args_impl_(std::tuple< As... > &evaled_args, std::integral_constant< std::size_t, I >, std::integral_constant< std::size_t, N > n, Ts... x)
void eval_args_impl_(std::tuple< As... > &, std::integral_constant< std::size_t, N >, std::integral_constant< std::size_t, N >, Ts...)
std::tuple< TemplatableValue< As, Ts... >... > Args
std::tuple< As... > eval_args_(Ts... x)
void play(Ts... x) override
ScriptExecuteAction(Script< As... > *script)
The abstract base class for all script types.
void execute_tuple_(const std::tuple< Ts... > &tuple, seq< S... >)
virtual bool is_running()
Check if any instance of this script is currently running.
virtual void execute(Ts...)=0
Execute a new instance of this script.
void execute_tuple(const std::tuple< Ts... > &tuple)
virtual void stop()
Stop all instances of this script.
void set_name(const LogString *name)
void esp_logd_(int line, const char *format, const char *param)
void esp_logd_(int line, const __FlashStringHelper *format, const char *param)
void esp_logw_(int line, const char *format, const char *param)
void esp_logw_(int line, const __FlashStringHelper *format, const char *param)
void esp_log_(int level, int line, const __FlashStringHelper *format, const char *param)
void play(Ts... x) override
ScriptStopAction(C *script)
void play_complex(Ts... x) override
ScriptWaitAction(C *script)
void play(Ts... x) override
A script type for which only a single instance at a time is allowed.
void execute(Ts... x) override
Providing packet encoding functions for exchanging data with a remote host.