Skip to content

Commit 93856e9

Browse files
committed
ESPHome DSMR component. Remove dependency on Arduino framework. Change the dependencies to the ones that don't require Arduino framework
1 parent 917deac commit 93856e9

File tree

5 files changed

+17
-28
lines changed

5 files changed

+17
-28
lines changed

.clang-tidy.hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3d46b63015d761c85ca9cb77ab79a389509e5776701fb22aed16e7b79d432c0c
1+
88a205b0fefeb3d1d1dc249944c3137ccc69c5b165d6a845468d9a3e18133ba3

esphome/components/dsmr/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def _validate_key(value):
6161
): cv.positive_time_period_milliseconds,
6262
}
6363
).extend(uart.UART_DEVICE_SCHEMA),
64-
cv.only_with_arduino,
6564
)
6665

6766

@@ -83,7 +82,7 @@ async def to_code(config):
8382
cg.add_build_flag("-DDSMR_WATER_MBUS_ID=" + str(config[CONF_WATER_MBUS_ID]))
8483

8584
# DSMR Parser
86-
cg.add_library("glmnet/Dsmr", "0.8")
85+
cg.add_library("polargoose/arduino-dsmr-2", "7.0")
8786

8887
# Crypto
89-
cg.add_library("rweather/Crypto", "0.4.0")
88+
cg.add_library("polargoose/Crypto-no-arduino", "0.4.0")

esphome/components/dsmr/dsmr.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#ifdef USE_ARDUINO
2-
31
#include "dsmr.h"
42
#include "esphome/core/log.h"
53

@@ -257,9 +255,9 @@ bool Dsmr::parse_telegram() {
257255
ESP_LOGV(TAG, "Trying to parse telegram");
258256
this->stop_requesting_data_();
259257

260-
::dsmr::ParseResult<void> res =
261-
::dsmr::P1Parser::parse(&data, this->telegram_, this->bytes_read_, false,
262-
this->crc_check_); // Parse telegram according to data definition. Ignore unknown values.
258+
const auto &res = arduino_dsmr_2::P1Parser::parse(
259+
&data, this->telegram_, this->bytes_read_, false,
260+
this->crc_check_); // Parse telegram according to data definition. Ignore unknown values.
263261
if (res.err) {
264262
// Parsing error, show it
265263
auto err_str = res.fullError(this->telegram_, this->telegram_ + this->bytes_read_);
@@ -331,5 +329,3 @@ void Dsmr::set_decryption_key(const std::string &decryption_key) {
331329

332330
} // namespace dsmr
333331
} // namespace esphome
334-
335-
#endif // USE_ARDUINO

esphome/components/dsmr/dsmr.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
#pragma once
22

3-
#ifdef USE_ARDUINO
4-
53
#include "esphome/core/component.h"
64
#include "esphome/components/sensor/sensor.h"
75
#include "esphome/components/text_sensor/text_sensor.h"
86
#include "esphome/components/uart/uart.h"
97
#include "esphome/core/log.h"
10-
#include "esphome/core/defines.h"
11-
12-
// don't include <dsmr.h> because it puts everything in global namespace
13-
#include <dsmr/parser.h>
14-
#include <dsmr/fields.h>
15-
8+
#include <arduino-dsmr-2/fields.h>
9+
#include <arduino-dsmr-2/parser.h>
1610
#include <vector>
1711

1812
namespace esphome {
1913
namespace dsmr {
2014

21-
using namespace ::dsmr::fields;
15+
using namespace arduino_dsmr_2::fields;
2216

2317
// DSMR_**_LIST generated by ESPHome and written in esphome/core/defines
2418

@@ -44,8 +38,8 @@ using namespace ::dsmr::fields;
4438
#define DSMR_DATA_SENSOR(s) s
4539
#define DSMR_COMMA ,
4640

47-
using MyData = ::dsmr::ParsedData<DSMR_TEXT_SENSOR_LIST(DSMR_DATA_SENSOR, DSMR_COMMA)
48-
DSMR_BOTH DSMR_SENSOR_LIST(DSMR_DATA_SENSOR, DSMR_COMMA)>;
41+
using MyData = arduino_dsmr_2::ParsedData<DSMR_TEXT_SENSOR_LIST(DSMR_DATA_SENSOR, DSMR_COMMA)
42+
DSMR_BOTH DSMR_SENSOR_LIST(DSMR_DATA_SENSOR, DSMR_COMMA)>;
4943

5044
class Dsmr : public Component, public uart::UARTDevice {
5145
public:
@@ -142,5 +136,3 @@ class Dsmr : public Component, public uart::UARTDevice {
142136
};
143137
} // namespace dsmr
144138
} // namespace esphome
145-
146-
#endif // USE_ARDUINO

platformio.ini

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ build_flags =
3333
; This are common settings for all environments.
3434
[common]
3535
lib_deps =
36-
esphome/noise-c@0.1.10 ; api
36+
esphome/noise-c@0.1.10 ; api
3737
improv/Improv@1.2.4 ; improv_serial / esp32_improv
3838
bblanchon/ArduinoJson@7.4.2 ; json
3939
wjtje/qr-code-generator-library@1.7.0 ; qr_code
4040
functionpointer/arduino-MLX90393@1.0.2 ; mlx90393
4141
pavlodn/HaierProtocol@0.9.31 ; haier
4242
kikuchan98/pngle@1.1.0 ; online_image
43+
polargoose/arduino-dsmr-2@7.0.0 ; dsmr
44+
polargoose/Crypto-no-arduino@0.4.0 ; dsmr
4345
https://github.com/esphome/TinyGPSPlus.git#v1.1.0 ; gps
4446
; Using the repository directly, otherwise ESP-IDF can't use the library
4547
https://github.com/bitbank2/JPEGDEC.git#ca1e0f2 ; online_image
@@ -78,8 +80,6 @@ lib_deps =
7880
heman/AsyncMqttClient-esphome@1.0.0 ; mqtt
7981
fastled/FastLED@3.9.16 ; fastled_base
8082
freekode/TM1651@1.0.1 ; tm1651
81-
glmnet/Dsmr@0.7 ; dsmr
82-
rweather/Crypto@0.4.0 ; dsmr
8383
dudanov/MideaUART@1.1.9 ; midea
8484
tonia/HeatpumpIR@1.0.37 ; heatpumpir
8585
build_flags =
@@ -234,10 +234,12 @@ build_flags =
234234
-DUSE_ZEPHYR
235235
-DUSE_NRF52
236236
lib_deps =
237-
bblanchon/ArduinoJson@7.4.2 ; json
237+
bblanchon/ArduinoJson@7.4.2 ; json
238238
wjtje/qr-code-generator-library@1.7.0 ; qr_code
239239
pavlodn/HaierProtocol@0.9.31 ; haier
240240
functionpointer/arduino-MLX90393@1.0.2 ; mlx90393
241+
polargoose/arduino-dsmr-2@7.0.0 ; dsmr
242+
polargoose/Crypto-no-arduino@0.4.0 ; dsmr
241243
https://github.com/esphome/TinyGPSPlus.git#v1.1.0 ; gps
242244
https://github.com/Sensirion/arduino-gas-index-algorithm.git#3.2.1 ; Sensirion Gas Index Algorithm Arduino Library
243245
lvgl/lvgl@8.4.0 ; lvgl

0 commit comments

Comments
 (0)