diff --git a/esphome/components/cse7766/cse7766.cpp b/esphome/components/cse7766/cse7766.cpp index 3907c195d0..88a91e374a 100644 --- a/esphome/components/cse7766/cse7766.cpp +++ b/esphome/components/cse7766/cse7766.cpp @@ -1,8 +1,5 @@ #include "cse7766.h" #include "esphome/core/log.h" -#include -#include -#include namespace esphome { namespace cse7766 { @@ -72,12 +69,8 @@ bool CSE7766Component::check_byte_() { void CSE7766Component::parse_data_() { #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE { - std::stringstream ss; - ss << "Raw data:" << std::hex << std::uppercase << std::setfill('0'); - for (uint8_t i = 0; i < 23; i++) { - ss << ' ' << std::setw(2) << static_cast(this->raw_data_[i]); - } - ESP_LOGVV(TAG, "%s", ss.str().c_str()); + std::string s = format_hex_pretty(this->raw_data_, sizeof(this->raw_data_)); + ESP_LOGVV(TAG, "Raw data: %s", s.c_str()); } #endif @@ -211,21 +204,20 @@ void CSE7766Component::parse_data_() { #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE { - std::stringstream ss; - ss << "Parsed:"; + std::string buf = "Parsed:"; if (have_voltage) { - ss << " V=" << voltage << "V"; + buf += str_sprintf(" V=%fV", voltage); } if (have_current) { - ss << " I=" << current * 1000.0f << "mA (~" << calculated_current * 1000.0f << "mA)"; + buf += str_sprintf(" I=%fmA (~%fmA)", current * 1000.0f, calculated_current * 1000.0f); } if (have_power) { - ss << " P=" << power << "W"; + buf += str_sprintf(" P=%fW", power); } if (energy != 0.0f) { - ss << " E=" << energy << "kWh (" << cf_pulses << ")"; + buf += str_sprintf(" E=%fkWh (%u)", energy, cf_pulses); } - ESP_LOGVV(TAG, "%s", ss.str().c_str()); + ESP_LOGVV(TAG, "%s", buf.c_str()); } #endif } diff --git a/esphome/components/graph/graph.cpp b/esphome/components/graph/graph.cpp index 09f7557714..cbe059b255 100644 --- a/esphome/components/graph/graph.cpp +++ b/esphome/components/graph/graph.cpp @@ -4,9 +4,6 @@ #include "esphome/core/log.h" #include "esphome/core/hal.h" #include -#include -#include // std::cout, std::fixed -#include namespace esphome { namespace graph { @@ -231,9 +228,8 @@ void GraphLegend::init(Graph *g) { ESP_LOGI(TAGL, " %s %d %d", txtstr.c_str(), fw, fh); if (this->values_ != VALUE_POSITION_TYPE_NONE) { - std::stringstream ss; - ss << std::fixed << std::setprecision(trace->sensor_->get_accuracy_decimals()) << trace->sensor_->get_state(); - std::string valstr = ss.str(); + std::string valstr = + value_accuracy_to_string(trace->sensor_->get_state(), trace->sensor_->get_accuracy_decimals()); if (this->units_) { valstr += trace->sensor_->get_unit_of_measurement(); } @@ -368,9 +364,8 @@ void Graph::draw_legend(display::Display *buff, uint16_t x_offset, uint16_t y_of if (legend_->values_ != VALUE_POSITION_TYPE_NONE) { int xv = x + legend_->xv_; int yv = y + legend_->yv_; - std::stringstream ss; - ss << std::fixed << std::setprecision(trace->sensor_->get_accuracy_decimals()) << trace->sensor_->get_state(); - std::string valstr = ss.str(); + std::string valstr = + value_accuracy_to_string(trace->sensor_->get_state(), trace->sensor_->get_accuracy_decimals()); if (legend_->units_) { valstr += trace->sensor_->get_unit_of_measurement(); } diff --git a/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp index acdcacc083..89e86741b0 100644 --- a/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp +++ b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp @@ -1,8 +1,6 @@ #include "modbus_textsensor.h" #include "esphome/core/log.h" -#include -#include namespace esphome { namespace modbus_controller { @@ -12,20 +10,17 @@ static const char *const TAG = "modbus_controller.text_sensor"; void ModbusTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Modbus Controller Text Sensor", this); } void ModbusTextSensor::parse_and_publish(const std::vector &data) { - std::ostringstream output; + std::string output_str{}; uint8_t items_left = this->response_bytes; uint8_t index = this->offset; - char buffer[5]; while ((items_left > 0) && index < data.size()) { uint8_t b = data[index]; switch (this->encode_) { case RawEncoding::HEXBYTES: - sprintf(buffer, "%02x", b); - output << buffer; + output_str += str_snprintf("%02x", 2, b); break; case RawEncoding::COMMA: - sprintf(buffer, index != this->offset ? ",%d" : "%d", b); - output << buffer; + output_str += str_sprintf(index != this->offset ? ",%d" : "%d", b); break; case RawEncoding::ANSI: if (b < 0x20) @@ -33,25 +28,24 @@ void ModbusTextSensor::parse_and_publish(const std::vector &data) { // FALLTHROUGH // Anything else no encoding default: - output << (char) b; + output_str += (char) b; break; } items_left--; index++; } - auto result = output.str(); // Is there a lambda registered // call it with the pre converted value and the raw data array if (this->transform_func_.has_value()) { // the lambda can parse the response itself - auto val = (*this->transform_func_)(this, result, data); + auto val = (*this->transform_func_)(this, output_str, data); if (val.has_value()) { ESP_LOGV(TAG, "Value overwritten by lambda"); - result = val.value(); + output_str = val.value(); } } - this->publish_state(result); + this->publish_state(output_str); } } // namespace modbus_controller diff --git a/esphome/const.py b/esphome/const.py index 696cc599fc..7390187d7e 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.2.0b1" +__version__ = "2025.2.0b2" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index 2d856d99c5..2a7b8b9d91 100644 --- a/esphome/core/__init__.py +++ b/esphome/core/__init__.py @@ -582,7 +582,7 @@ class EsphomeCore: @property def config_dir(self): - return os.path.dirname(os.path.abspath(self.config_path)) + return os.path.abspath(os.path.dirname(self.config_path)) @property def data_dir(self): diff --git a/esphome/core/config.py b/esphome/core/config.py index 7152414463..2077af02a7 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -217,6 +217,8 @@ def preload_core_config(config, result) -> str: target_platforms = [] for domain, _ in config.items(): + if domain.startswith("."): + continue if _is_target_platform(domain): target_platforms += [domain] diff --git a/requirements.txt b/requirements.txt index bbf0ae7f3d..8eca21c4bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ esptool==4.7.0 click==8.1.7 esphome-dashboard==20250212.0 aioesphomeapi==24.6.2 -zeroconf==0.143.0 +zeroconf==0.144.1 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import glyphsets==1.0.0