1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-15 07:08:20 +00:00

[sgp30] Fix reading from preexisting stored baseline even with store_baseline: false

This commit is contained in:
Chaser Huang 2024-12-04 22:46:11 -05:00
parent 016fac2496
commit b88508bc43

View File

@ -79,7 +79,7 @@ void SGP30Component::setup() {
uint32_t hash = fnv1_hash(App.get_compilation_time() + std::to_string(this->serial_number_)); uint32_t hash = fnv1_hash(App.get_compilation_time() + std::to_string(this->serial_number_));
this->pref_ = global_preferences->make_preference<SGP30Baselines>(hash, true); this->pref_ = global_preferences->make_preference<SGP30Baselines>(hash, true);
if (this->pref_.load(&this->baselines_storage_)) { if (this->store_baseline_ && this->pref_.load(&this->baselines_storage_)) {
ESP_LOGI(TAG, "Loaded eCO2 baseline: 0x%04X, TVOC baseline: 0x%04X", this->baselines_storage_.eco2, ESP_LOGI(TAG, "Loaded eCO2 baseline: 0x%04X, TVOC baseline: 0x%04X", this->baselines_storage_.eco2,
baselines_storage_.tvoc); baselines_storage_.tvoc);
this->eco2_baseline_ = this->baselines_storage_.eco2; this->eco2_baseline_ = this->baselines_storage_.eco2;