mirror of
https://github.com/esphome/esphome.git
synced 2025-07-27 13:46:48 +00:00
adju
This commit is contained in:
parent
2d15a3c0e8
commit
f4cb2d540d
@ -51,14 +51,16 @@ template<typename... Ts> class HomeAssistantServiceCallAction : public Action<Ts
|
|||||||
|
|
||||||
template<typename T> void set_service(T service) { this->service_ = service; }
|
template<typename T> void set_service(T service) { this->service_ = service; }
|
||||||
|
|
||||||
// These methods use const std::string& for keys because keys are always string literals
|
// Keys are always string literals from the Python code generation (e.g., cg.add(var.add_data("tag_id", templ))).
|
||||||
// from the Python code generation (e.g., cg.add(var.add_data("tag_id", templ))).
|
|
||||||
// The value parameter can be a lambda/template, but keys are never templatable.
|
// The value parameter can be a lambda/template, but keys are never templatable.
|
||||||
template<typename T> void add_data(const std::string &key, T value) { this->data_.emplace_back(key, value); }
|
// Using pass-by-value allows the compiler to optimize for both lvalues and rvalues.
|
||||||
template<typename T> void add_data_template(const std::string &key, T value) {
|
template<typename T> void add_data(std::string key, T value) { this->data_.emplace_back(std::move(key), value); }
|
||||||
this->data_template_.emplace_back(key, value);
|
template<typename T> void add_data_template(std::string key, T value) {
|
||||||
|
this->data_template_.emplace_back(std::move(key), value);
|
||||||
|
}
|
||||||
|
template<typename T> void add_variable(std::string key, T value) {
|
||||||
|
this->variables_.emplace_back(std::move(key), value);
|
||||||
}
|
}
|
||||||
template<typename T> void add_variable(const std::string &key, T value) { this->variables_.emplace_back(key, value); }
|
|
||||||
|
|
||||||
void play(Ts... x) override {
|
void play(Ts... x) override {
|
||||||
HomeassistantServiceResponse resp;
|
HomeassistantServiceResponse resp;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user