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> Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Co-authored-by: edenhaus <edenhaus@users.noreply.github.com> Co-authored-by: J. Nick Koston <nick@home-assistant.io> Co-authored-by: J. Nick Koston <nick+github@koston.org>
31 lines
831 B
C++
31 lines
831 B
C++
#include "micronova_sensor.h"
|
|
|
|
namespace esphome::micronova {
|
|
|
|
static const char *const TAG = "micronova.sensor";
|
|
|
|
void MicroNovaSensor::dump_config() {
|
|
LOG_SENSOR("", "Micronova sensor", this);
|
|
this->dump_base_config();
|
|
}
|
|
|
|
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
|