diff --git a/esphome/components/output/float_output.h b/esphome/components/output/float_output.h index 94509d56a3..85f3bdcf7b 100644 --- a/esphome/components/output/float_output.h +++ b/esphome/components/output/float_output.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/core/component.h" +#include "esphome/core/helpers.h" #include "binary_output.h" namespace esphome { @@ -9,12 +10,10 @@ namespace output { #define LOG_FLOAT_OUTPUT(this) \ LOG_BINARY_OUTPUT(this) \ if (this->max_power_ != 1.0f) { \ - int _mp = static_cast(this->max_power_ * 1000.0f); \ - ESP_LOGCONFIG(TAG, " Max Power: %s%d.%d%%", _mp < 0 ? "-" : "", std::abs(_mp / 10), std::abs(_mp % 10)); \ + ESP_LOGCONFIG(TAG, " Max Power: %s%d.%d%%", DECIMAL_1(this->max_power_ * 100.0f)); \ } \ if (this->min_power_ != 0.0f) { \ - int _mp = static_cast(this->min_power_ * 1000.0f); \ - ESP_LOGCONFIG(TAG, " Min Power: %s%d.%d%%", _mp < 0 ? "-" : "", std::abs(_mp / 10), std::abs(_mp % 10)); \ + ESP_LOGCONFIG(TAG, " Min Power: %s%d.%d%%", DECIMAL_1(this->min_power_ * 100.0f)); \ } /** Base class for all output components that can output a variable level, like PWM. diff --git a/esphome/core/component.cpp b/esphome/core/component.cpp index 98e8c02d07..d1556c086e 100644 --- a/esphome/core/component.cpp +++ b/esphome/core/component.cpp @@ -450,9 +450,12 @@ void log_update_interval(const char *tag, PollingComponent *component) { if (update_interval == SCHEDULER_DONT_RUN) { ESP_LOGCONFIG(tag, " Update Interval: never"); } else if (update_interval < 100) { - ESP_LOGCONFIG(tag, " Update Interval: %.3fs", update_interval / 1000.0f); + // Use integer math to avoid pulling in _dtoa_r (~3.4KB) + // update_interval is in ms, display as X.YYYs + ESP_LOGCONFIG(tag, " Update Interval: %d.%03ds", update_interval / 1000, update_interval % 1000); } else { - ESP_LOGCONFIG(tag, " Update Interval: %.1fs", update_interval / 1000.0f); + // Display as X.Ys (1 decimal place) + ESP_LOGCONFIG(tag, " Update Interval: %d.%ds", update_interval / 1000, (update_interval % 1000) / 100); } } float Component::get_actual_setup_priority() const {