Tomer27cz 2026-04-03 23:38:38 +02:00
parent c0b9ae9dec
commit 2d556d1a70
2 changed files with 5 additions and 2 deletions

View File

@ -30,7 +30,9 @@ static void log_callback(dlms_parser::LogLevel level, const char *fmt, va_list a
void DlmsMeterLibComponent::setup() { void DlmsMeterLibComponent::setup() {
dlms_parser::Logger::set_log_function(log_callback); dlms_parser::Logger::set_log_function(log_callback);
this->parser_.load_default_patterns(); this->parser_ = std::make_unique<dlms_parser::DlmsParser>();
this->parser_->load_default_patterns();
this->rx_buffer_ = std::make_unique<uint8_t[]>(MAX_RX_BUFFER_SIZE); this->rx_buffer_ = std::make_unique<uint8_t[]>(MAX_RX_BUFFER_SIZE);
this->rx_buffer_len_ = 0; this->rx_buffer_len_ = 0;
} }

View File

@ -1,6 +1,7 @@
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/defines.h" #include "esphome/core/defines.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/components/uart/uart.h"
#ifdef USE_SENSOR #ifdef USE_SENSOR
#include "esphome/components/sensor/sensor.h" #include "esphome/components/sensor/sensor.h"
@ -69,7 +70,7 @@ class DlmsMeterLibComponent : public Component, public uart::UARTDevice {
uint32_t receive_timeout_ms_{50}; uint32_t receive_timeout_ms_{50};
std::string custom_pattern_{""}; std::string custom_pattern_{""};
std::unique_ptr<DlmsParser> parser_; std::unique_ptr<dlms_parser::DlmsParser> parser_;
#ifdef USE_SENSOR #ifdef USE_SENSOR
struct NumericSensorEntry { struct NumericSensorEntry {