[sfa30] Fix negative temperature values (#11973)

This commit is contained in:
Jonathan Swoboda
2025-11-18 13:29:40 -05:00
committed by GitHub
parent fe2befcec2
commit 72e4b16a5b
+3 -3
View File
@@ -73,17 +73,17 @@ void SFA30Component::update() {
} }
if (this->formaldehyde_sensor_ != nullptr) { if (this->formaldehyde_sensor_ != nullptr) {
const float formaldehyde = raw_data[0] / 5.0f; const float formaldehyde = static_cast<int16_t>(raw_data[0]) / 5.0f;
this->formaldehyde_sensor_->publish_state(formaldehyde); this->formaldehyde_sensor_->publish_state(formaldehyde);
} }
if (this->humidity_sensor_ != nullptr) { if (this->humidity_sensor_ != nullptr) {
const float humidity = raw_data[1] / 100.0f; const float humidity = static_cast<int16_t>(raw_data[1]) / 100.0f;
this->humidity_sensor_->publish_state(humidity); this->humidity_sensor_->publish_state(humidity);
} }
if (this->temperature_sensor_ != nullptr) { if (this->temperature_sensor_ != nullptr) {
const float temperature = raw_data[2] / 200.0f; const float temperature = static_cast<int16_t>(raw_data[2]) / 200.0f;
this->temperature_sensor_->publish_state(temperature); this->temperature_sensor_->publish_state(temperature);
} }