mirror of
https://github.com/esphome/esphome.git
synced 2026-09-02 11:06:04 +00:00
[binary_sensor] Inline send_state_internal - virtual dispatch prevents template bloat
This commit is contained in:
@@ -32,10 +32,6 @@ void BinarySensor::publish_initial_state(bool new_state) {
|
||||
this->invalidate_state();
|
||||
this->publish_state(new_state);
|
||||
}
|
||||
// Defined out-of-line: set_new_state is virtual so callers in other TUs (filter.cpp, automation.h)
|
||||
// dispatch here without inlining the ~189 byte template body at each call site.
|
||||
void BinarySensor::send_state_internal(bool new_state) { this->set_new_state(new_state); }
|
||||
|
||||
bool BinarySensor::set_new_state(const optional<bool> &new_state) {
|
||||
if (StatefulEntityBase::set_new_state(new_state)) {
|
||||
#if defined(USE_BINARY_SENSOR) && defined(USE_CONTROLLER_REGISTRY)
|
||||
|
||||
@@ -57,7 +57,7 @@ class BinarySensor : public StatefulEntityBase<bool> {
|
||||
|
||||
// ========== INTERNAL METHODS ==========
|
||||
// (In most use cases you won't need these)
|
||||
void send_state_internal(bool new_state);
|
||||
void send_state_internal(bool new_state) { this->set_new_state(new_state); }
|
||||
|
||||
/// Return whether this binary sensor has outputted a state.
|
||||
virtual bool is_status_binary_sensor() const;
|
||||
|
||||
Reference in New Issue
Block a user