diff --git a/esphome/core/entity_base.h b/esphome/core/entity_base.h index 63ebaca62f0..e542d60e65e 100644 --- a/esphome/core/entity_base.h +++ b/esphome/core/entity_base.h @@ -348,9 +348,8 @@ template class StatefulEntityBase : public EntityBase { if (new_state.has_value()) { if (had_state && this->get_state() == new_state.value()) return false; // same value, no change - } else { - if (!had_state) - return false; // already invalidated, no change + } else if (!had_state) { + return false; // already invalidated, no change } // State changed — capture old state, then update storage before firing callbacks // so callback code can inspect the entity's current state via get_state()/has_state()