mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-03 08:31:47 +00:00 
			
		
		
		
	Compare commits
	
		
			8 Commits
		
	
	
		
			2025.2.0b1
			...
			2025.2.0b2
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					897873496a | ||
| 
						 | 
					b0f6dd7d9c | ||
| 
						 | 
					be5639faf1 | ||
| 
						 | 
					e9a537784e | ||
| 
						 | 
					35d303809e | ||
| 
						 | 
					4740f12ce8 | ||
| 
						 | 
					c8e7e275a4 | ||
| 
						 | 
					077ee5b714 | 
@@ -1,8 +1,5 @@
 | 
			
		||||
#include "cse7766.h"
 | 
			
		||||
#include "esphome/core/log.h"
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
#include <iomanip>
 | 
			
		||||
#include <sstream>
 | 
			
		||||
 | 
			
		||||
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<unsigned>(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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,9 +4,6 @@
 | 
			
		||||
#include "esphome/core/log.h"
 | 
			
		||||
#include "esphome/core/hal.h"
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <sstream>
 | 
			
		||||
#include <iostream>  // std::cout, std::fixed
 | 
			
		||||
#include <iomanip>
 | 
			
		||||
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();
 | 
			
		||||
      }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,6 @@
 | 
			
		||||
 | 
			
		||||
#include "modbus_textsensor.h"
 | 
			
		||||
#include "esphome/core/log.h"
 | 
			
		||||
#include <iomanip>
 | 
			
		||||
#include <sstream>
 | 
			
		||||
 | 
			
		||||
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<uint8_t> &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<uint8_t> &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
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
"""Constants used by esphome."""
 | 
			
		||||
 | 
			
		||||
__version__ = "2025.2.0b1"
 | 
			
		||||
__version__ = "2025.2.0b2"
 | 
			
		||||
 | 
			
		||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
 | 
			
		||||
VALID_SUBSTITUTIONS_CHARACTERS = (
 | 
			
		||||
 
 | 
			
		||||
@@ -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):
 | 
			
		||||
 
 | 
			
		||||
@@ -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]
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user