Files
esphome-lsm6ds/esphome/components/micronova/sensor/micronova_sensor.cpp
T
3eaa9f164b [micronova] Remove MicroNovaFunctions (#12363)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-08 14:38:13 -05:00

24 lines
666 B
C++

#include "micronova_sensor.h"
namespace esphome::micronova {
void MicroNovaSensor::process_value_from_stove(int value_from_stove) {
if (value_from_stove == -1) {
this->publish_state(NAN);
return;
}
float new_sensor_value = static_cast<float>(value_from_stove);
// Fan speed has special calculation: value * 10 + offset (when non-zero)
if (this->is_fan_speed_) {
new_sensor_value = value_from_stove == 0 ? 0.0f : (new_sensor_value * 10) + this->fan_speed_offset_;
} else if (this->divisor_ > 1) {
new_sensor_value = new_sensor_value / this->divisor_;
}
this->publish_state(new_sensor_value);
}
} // namespace esphome::micronova