1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-05 11:23:47 +01:00

Dsmr updates (#2157)

* add option to use check_crc

* ignore newline before ( in parsing

* add gas delivered text for raw sensor

* fix compile issue when not listing any sensor

* make gas_mbus_id configurable

* update dsmr lib for clang
This commit is contained in:
Guillermo Ruffino
2021-09-14 22:14:49 -03:00
committed by GitHub
parent 103ba4c696
commit de33cbd7e7
6 changed files with 33 additions and 10 deletions

View File

@@ -37,6 +37,12 @@ void Dsmr::receive_telegram_() {
return;
}
// Some v2.2 or v3 meters will send a new value which starts with '('
// in a new line while the value belongs to the previous ObisId. For
// proper parsing remove these new line characters
while (c == '(' && (telegram_[telegram_len_ - 1] == '\n' || telegram_[telegram_len_ - 1] == '\r'))
telegram_len_--;
telegram_[telegram_len_] = c;
telegram_len_++;
if (c == '!') { // footer: exclamation mark
@@ -130,8 +136,8 @@ bool Dsmr::parse_telegram() {
MyData data;
ESP_LOGV(TAG, "Trying to parse");
::dsmr::ParseResult<void> res =
::dsmr::P1Parser::parse(&data, telegram_, telegram_len_,
false); // Parse telegram according to data definition. Ignore unknown values.
::dsmr::P1Parser::parse(&data, telegram_, telegram_len_, false,
this->crc_check_); // Parse telegram according to data definition. Ignore unknown values.
if (res.err) {
// Parsing error, show it
auto err_str = res.fullError(telegram_, telegram_ + telegram_len_);