mirror of
https://github.com/esphome/esphome.git
synced 2026-05-28 04:55:48 +08:00
[sfa30] Fix negative temperature values (#11973)
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user