From 3bc7efb479f4cb5feb6141252cf77b7938c16159 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 19 Mar 2026 00:04:55 -1000 Subject: [PATCH] [binary_sensor] Replace std::bind with inline lambda in MultiClickTrigger Replace std::bind(&MultiClickTrigger::on_state_, this, _1) with a [this] lambda for the add_on_state_callback registration. The [this] lambda fits within the Callback inline storage threshold (sizeof(void*)), avoiding a permanent heap allocation. --- esphome/components/binary_sensor/automation.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/esphome/components/binary_sensor/automation.h b/esphome/components/binary_sensor/automation.h index f8b130e08a..f30f9d3279 100644 --- a/esphome/components/binary_sensor/automation.h +++ b/esphome/components/binary_sensor/automation.h @@ -96,8 +96,7 @@ class MultiClickTrigger : public Trigger<>, public Component { void setup() override { this->last_state_ = this->parent_->get_state_default(false); - auto f = std::bind(&MultiClickTrigger::on_state_, this, std::placeholders::_1); - this->parent_->add_on_state_callback(f); + this->parent_->add_on_state_callback([this](bool state) { this->on_state_(state); }); } float get_setup_priority() const override { return setup_priority::HARDWARE; }