diff --git a/esphome/components/api/homeassistant_service.h b/esphome/components/api/homeassistant_service.h index 6df29f2963..9dcfdec7cf 100644 --- a/esphome/components/api/homeassistant_service.h +++ b/esphome/components/api/homeassistant_service.h @@ -36,7 +36,7 @@ template class TemplatableStringValue : public TemplatableValue class TemplatableKeyValuePair { public: - template TemplatableKeyValuePair(std::string key, T value) : key(std::move(key)), value(value) {} + template TemplatableKeyValuePair(const std::string &key, T value) : key(key), value(value) {} std::string key; TemplatableStringValue value; }; @@ -47,11 +47,11 @@ template class HomeAssistantServiceCallAction : public Action void set_service(T service) { this->service_ = service; } - template void add_data(std::string key, T value) { this->data_.emplace_back(key, value); } - template void add_data_template(std::string key, T value) { + template void add_data(const std::string &key, T value) { this->data_.emplace_back(key, value); } + template void add_data_template(const std::string &key, T value) { this->data_template_.emplace_back(key, value); } - template void add_variable(std::string key, T value) { this->variables_.emplace_back(key, value); } + template void add_variable(const std::string &key, T value) { this->variables_.emplace_back(key, value); } void play(Ts... x) override { HomeassistantServiceResponse resp;