From 8aa9a82c13835cad02d520f4bcc0061c32dbdfe5 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 22 Mar 2026 16:43:37 -1000 Subject: [PATCH] [binary_sensor] Clarify trigger_on_initial_state docs - subclass decides storage --- esphome/core/entity_base.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/esphome/core/entity_base.h b/esphome/core/entity_base.h index 8b3e426b588..4ea7d069874 100644 --- a/esphome/core/entity_base.h +++ b/esphome/core/entity_base.h @@ -304,7 +304,8 @@ void log_entity_unit_of_measurement(const char *tag, const char *prefix, const E * Subclasses must implement: * - get_state(): return a const reference to the current value * - set_state_value(): store a new value (called only when the state actually changes) - * - get_trigger_on_initial_state() / set_trigger_on_initial_state(): control initial callback behavior + * - get_trigger_on_initial_state(): return whether callbacks should fire on the first state + * - set_trigger_on_initial_state(): store the value (subclass decides how) * * Subclasses may override set_new_state() to add behavior (logging, notifications) after calling * the base implementation. Since set_new_state() is virtual, callers like invalidate_state() and @@ -335,7 +336,7 @@ template class StatefulEntityBase : public EntityBase { } /// Control whether state_callbacks_ fire on the very first state (before any previous state exists). - /// Subclasses must implement set_trigger_on_initial_state() to store this value. + /// Subclasses decide how to store the value. virtual void set_trigger_on_initial_state(bool value) = 0; protected: