[template.output] Avoid heap allocation for triggers (#13709)
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled

This commit is contained in:
J. Nick Koston
2026-02-02 07:36:27 +01:00
committed by GitHub
parent 6114005952
commit 62f34bea83
@@ -8,22 +8,22 @@ namespace esphome::template_ {
class TemplateBinaryOutput final : public output::BinaryOutput {
public:
Trigger<bool> *get_trigger() const { return trigger_; }
Trigger<bool> *get_trigger() { return &this->trigger_; }
protected:
void write_state(bool state) override { this->trigger_->trigger(state); }
void write_state(bool state) override { this->trigger_.trigger(state); }
Trigger<bool> *trigger_ = new Trigger<bool>();
Trigger<bool> trigger_;
};
class TemplateFloatOutput final : public output::FloatOutput {
public:
Trigger<float> *get_trigger() const { return trigger_; }
Trigger<float> *get_trigger() { return &this->trigger_; }
protected:
void write_state(float state) override { this->trigger_->trigger(state); }
void write_state(float state) override { this->trigger_.trigger(state); }
Trigger<float> *trigger_ = new Trigger<float>();
Trigger<float> trigger_;
};
} // namespace esphome::template_