mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
[sgp4x] Fix undefined behavior from mutating entity config at runtime (#14562)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -35,13 +35,9 @@ void SGP4xComponent::setup() {
|
||||
this->self_test_time_ = SPG40_SELFTEST_TIME;
|
||||
this->measure_time_ = SGP40_MEASURE_TIME;
|
||||
if (this->nox_sensor_) {
|
||||
ESP_LOGE(TAG, "SGP41 required for NOx");
|
||||
// disable the sensor
|
||||
this->nox_sensor_->set_disabled_by_default(true);
|
||||
// make sure it's not visible in HA
|
||||
this->nox_sensor_->set_internal(true);
|
||||
this->nox_sensor_->state = NAN;
|
||||
// remove pointer to sensor
|
||||
ESP_LOGE(TAG, "SGP41 required for NOx, disabling NOx sensor");
|
||||
// Drop the pointer so update() never publishes to it.
|
||||
// The entity remains registered but will never receive state updates.
|
||||
this->nox_sensor_ = nullptr;
|
||||
}
|
||||
} else if (featureset == SGP41_FEATURESET) {
|
||||
|
||||
Reference in New Issue
Block a user