mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 23:21:54 +00:00 
			
		
		
		
	Fix wrong type for voc_state*_ in sgp4x component (#3581)
Co-authored-by: Martin <25747549+martgras@users.noreply.github.com> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
		| @@ -140,5 +140,7 @@ async def to_code(config): | |||||||
|                 ) |                 ) | ||||||
|             ) |             ) | ||||||
|     cg.add_library( |     cg.add_library( | ||||||
|         None, None, "https://github.com/Sensirion/arduino-gas-index-algorithm.git" |         None, | ||||||
|  |         None, | ||||||
|  |         "https://github.com/Sensirion/arduino-gas-index-algorithm.git#3.2.1", | ||||||
|     ) |     ) | ||||||
|   | |||||||
| @@ -170,8 +170,8 @@ bool SGP4xComponent::measure_gas_indices_(int32_t &voc, int32_t &nox) { | |||||||
|   // much |   // much | ||||||
|   if (this->store_baseline_ && this->seconds_since_last_store_ > SHORTEST_BASELINE_STORE_INTERVAL) { |   if (this->store_baseline_ && this->seconds_since_last_store_ > SHORTEST_BASELINE_STORE_INTERVAL) { | ||||||
|     voc_algorithm_.get_states(this->voc_state0_, this->voc_state1_); |     voc_algorithm_.get_states(this->voc_state0_, this->voc_state1_); | ||||||
|     if ((uint32_t) abs(this->voc_baselines_storage_.state0 - this->voc_state0_) > MAXIMUM_STORAGE_DIFF || |     if (std::abs(this->voc_baselines_storage_.state0 - this->voc_state0_) > MAXIMUM_STORAGE_DIFF || | ||||||
|         (uint32_t) abs(this->voc_baselines_storage_.state1 - this->voc_state1_) > MAXIMUM_STORAGE_DIFF) { |         std::abs(this->voc_baselines_storage_.state1 - this->voc_state1_) > MAXIMUM_STORAGE_DIFF) { | ||||||
|       this->seconds_since_last_store_ = 0; |       this->seconds_since_last_store_ = 0; | ||||||
|       this->voc_baselines_storage_.state0 = this->voc_state0_; |       this->voc_baselines_storage_.state0 = this->voc_state0_; | ||||||
|       this->voc_baselines_storage_.state1 = this->voc_state1_; |       this->voc_baselines_storage_.state1 = this->voc_state1_; | ||||||
|   | |||||||
| @@ -49,7 +49,7 @@ static const uint16_t SPG41_SELFTEST_TIME = 320;  // 320 ms for self test | |||||||
| static const uint16_t SGP40_MEASURE_TIME = 30; | static const uint16_t SGP40_MEASURE_TIME = 30; | ||||||
| static const uint16_t SGP41_MEASURE_TIME = 55; | static const uint16_t SGP41_MEASURE_TIME = 55; | ||||||
| // Store anyway if the baseline difference exceeds the max storage diff value | // Store anyway if the baseline difference exceeds the max storage diff value | ||||||
| const uint32_t MAXIMUM_STORAGE_DIFF = 50; | const float MAXIMUM_STORAGE_DIFF = 50.0f; | ||||||
|  |  | ||||||
| class SGP4xComponent; | class SGP4xComponent; | ||||||
|  |  | ||||||
| @@ -120,8 +120,8 @@ class SGP4xComponent : public PollingComponent, public sensor::Sensor, public se | |||||||
|   sensor::Sensor *voc_sensor_{nullptr}; |   sensor::Sensor *voc_sensor_{nullptr}; | ||||||
|   VOCGasIndexAlgorithm voc_algorithm_; |   VOCGasIndexAlgorithm voc_algorithm_; | ||||||
|   optional<GasTuning> voc_tuning_params_; |   optional<GasTuning> voc_tuning_params_; | ||||||
|   int32_t voc_state0_; |   float voc_state0_; | ||||||
|   int32_t voc_state1_; |   float voc_state1_; | ||||||
|   int32_t voc_index_ = 0; |   int32_t voc_index_ = 0; | ||||||
|  |  | ||||||
|   sensor::Sensor *nox_sensor_{nullptr}; |   sensor::Sensor *nox_sensor_{nullptr}; | ||||||
|   | |||||||
| @@ -40,7 +40,7 @@ lib_deps = | |||||||
|     wjtje/qr-code-generator-library@1.7.0  ; qr_code |     wjtje/qr-code-generator-library@1.7.0  ; qr_code | ||||||
|     functionpointer/arduino-MLX90393@1.0.0 ; mlx90393 |     functionpointer/arduino-MLX90393@1.0.0 ; mlx90393 | ||||||
|     ; This is using the repository until a new release is published to PlatformIO |     ; This is using the repository until a new release is published to PlatformIO | ||||||
|     https://github.com/Sensirion/arduino-gas-index-algorithm.git ; Sensirion Gas Index Algorithm Arduino Library |     https://github.com/Sensirion/arduino-gas-index-algorithm.git#3.2.1 ; Sensirion Gas Index Algorithm Arduino Library | ||||||
| build_flags = | build_flags = | ||||||
|     -DESPHOME_LOG_LEVEL=ESPHOME_LOG_LEVEL_VERY_VERBOSE |     -DESPHOME_LOG_LEVEL=ESPHOME_LOG_LEVEL_VERY_VERBOSE | ||||||
| src_filter = | src_filter = | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user