Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SML checksum error since merge of #5250 #4803

Closed
MrXermon opened this issue Aug 17, 2023 · 16 comments · Fixed by esphome/esphome#5271
Closed

SML checksum error since merge of #5250 #4803

MrXermon opened this issue Aug 17, 2023 · 16 comments · Fixed by esphome/esphome#5271

Comments

@MrXermon
Copy link

The problem

I initially reported a bug regarding the values of my DWS7412.2.G2 meter not being decoded correctly (#4494). Since the merge of Fix 24 bit signed integer parsing in sml parser #5250, ESPHome shows checksum errors which causes no data to be extracted anymore.

Which version of ESPHome has the issue?

2023.8.0

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2023.8.2

What platform are you using?

ESP8266

Board

Wemos D1 Mini

Component causing the issue

sml

Example YAML snippet

uart:
  id: uart_bus
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 9600
  data_bits: 8
  parity: NONE
  stop_bits: 1

sml:
  id: mysml
  uart_id: uart_bus

sensor:
  - platform: sml
    name: "SML Total In"
    sml_id: mysml
    obis_code: "1-0:1.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 2
    device_class: energy
    state_class: total_increasing
    filters:
      - multiply: 0.0001
  - platform: sml
    name: "SML Total Out"
    sml_id: mysml
    obis_code: "1-0:2.8.0"
    unit_of_measurement: kWh
    accuracy_decimals: 2
    device_class: energy
    state_class: total_increasing
    filters:
      - multiply: 0.0001
  - platform: sml
    name: "SML Current Power"
    sml_id: mysml
    obis_code: "1-0:16.7.0"
    unit_of_measurement: W
    accuracy_decimals: 2
    device_class: power
    state_class: measurement
    filters:
      - multiply: 0.01

Anything in the logs that might be useful for us?

[08:47:08][I][app:102]: ESPHome version 2023.8.0 compiled on Aug 17 2023, 08:45:14
[08:47:08][C][wifi:543]: WiFi:
[08:47:08][C][wifi:379]:   Local MAC: [redacted]
[08:47:08][C][wifi:380]:   SSID: [redacted]
[08:47:08][C][wifi:381]:   IP Address: [redacted]
[08:47:08][C][wifi:382]:   BSSID: [redacted]
[08:47:08][C][wifi:384]:   Hostname: [redacted]
[08:47:08][C][wifi:386]:   Signal strength: [redacted]
[08:47:08][C][wifi:390]:   Channel: [redacted]
[08:47:08][C][wifi:391]:   Subnet: [redacted]
[08:47:08][C][wifi:392]:   Gateway: [redacted]
[08:47:08][C][wifi:393]:   DNS1: [redacted]
[08:47:08][C][wifi:394]:   DNS2: [redacted]
[08:47:08][C][logger:301]: Logger:
[08:47:08][C][logger:302]:   Level: DEBUG
[08:47:08][C][logger:303]:   Log Baud Rate: 0
[08:47:08][C][logger:305]:   Hardware UART: UART0
[08:47:08][C][uart.arduino_esp8266:102]: UART Bus:
[08:47:08][C][uart.arduino_esp8266:103]:   TX Pin: GPIO1
[08:47:08][C][uart.arduino_esp8266:104]:   RX Pin: GPIO3
[08:47:08][C][uart.arduino_esp8266:106]:   RX Buffer Size: 256
[08:47:08][C][uart.arduino_esp8266:108]:   Baud Rate: 9600 baud
[08:47:08][C][uart.arduino_esp8266:109]:   Data Bits: 8
[08:47:08][C][uart.arduino_esp8266:110]:   Parity: NONE
[08:47:08][C][uart.arduino_esp8266:111]:   Stop bits: 1
[08:47:08][C][uart.arduino_esp8266:113]:   Using hardware serial interface.
[08:47:08][C][homeassistant.time:010]: Home Assistant Time:
[08:47:08][C][homeassistant.time:011]:   Timezone: 'CET-1CEST,M3.5.0,M10.5.0/3'
[08:47:08][C][sml:092]: SML:
[08:47:08][C][sml_sensor:033]: SML 'SML Total In'
[08:47:08][C][sml_sensor:033]:   Device Class: 'energy'
[08:47:08][C][sml_sensor:033]:   State Class: 'total_increasing'
[08:47:08][C][sml_sensor:033]:   Unit of Measurement: 'kWh'
[08:47:08][C][sml_sensor:033]:   Accuracy Decimals: 2
[08:47:08][C][sml_sensor:037]:   OBIS Code: 1-0:1.8.0
[08:47:08][C][sml_sensor:033]: SML 'SML Total Out'
[08:47:08][C][sml_sensor:033]:   Device Class: 'energy'
[08:47:08][C][sml_sensor:033]:   State Class: 'total_increasing'
[08:47:08][C][sml_sensor:033]:   Unit of Measurement: 'kWh'
[08:47:08][C][sml_sensor:033]:   Accuracy Decimals: 2
[08:47:08][C][sml_sensor:037]:   OBIS Code: 1-0:2.8.0
[08:47:08][C][sml_sensor:033]: SML 'SML Current Power'
[08:47:08][C][sml_sensor:033]:   Device Class: 'power'
[08:47:08][C][sml_sensor:033]:   State Class: 'measurement'
[08:47:08][C][sml_sensor:033]:   Unit of Measurement: 'W'
[08:47:08][C][sml_sensor:033]:   Accuracy Decimals: 2
[08:47:08][C][sml_sensor:037]:   OBIS Code: 1-0:16.7.0
[08:47:08][C][captive_portal:088]: Captive Portal:
[08:47:08][C][mdns:112]: mDNS:
[08:47:08][C][mdns:113]:   Hostname: [redacted]
[08:47:08][C][ota:093]: Over-The-Air Updates:
[08:47:08][C][ota:094]:   Address: [redacted]:8266
[08:47:08][C][ota:097]:   Using Password.
[08:47:08][C][api:138]: API Server:
[08:47:08][C][api:139]:   Address: [redacted]:6053
[08:47:08][C][api:143]:   Using noise encryption: NO
[08:47:08][W][sml:116]: Checksum error in received SML data.
[08:47:09][W][sml:116]: Checksum error in received SML data.
[08:47:09][D][api:102]: Accepted [redacted]
[08:47:09][D][api.connection:1031]: Home Assistant 2023.8.2 ([redacted]): Connected successfully
[08:47:09][D][time:044]: Synchronized time: 2023-08-17 08:47:09
[08:47:10][W][sml:116]: Checksum error in received SML data.
[08:47:11][W][sml:116]: Checksum error in received SML data.
[08:47:12][W][sml:116]: Checksum error in received SML data.
[08:47:13][W][sml:116]: Checksum error in received SML data.
[08:47:14][W][sml:116]: Checksum error in received SML data.
[08:47:15][W][sml:116]: Checksum error in received SML data.
[08:47:16][W][sml:116]: Checksum error in received SML data.
[08:47:17][W][sml:116]: Checksum error in received SML data.
[08:47:18][W][sml:116]: Checksum error in received SML data.
[08:47:19][W][sml:116]: Checksum error in received SML data.
[08:47:20][W][sml:116]: Checksum error in received SML data.
[08:47:21][W][sml:116]: Checksum error in received SML data.
[08:47:22][W][sml:116]: Checksum error in received SML data.
[08:47:23][W][sml:116]: Checksum error in received SML data.
[08:47:24][W][sml:116]: Checksum error in received SML data.
[08:47:25][W][sml:116]: Checksum error in received SML data.
[08:47:26][W][sml:116]: Checksum error in received SML data.
[08:47:27][W][sml:116]: Checksum error in received SML data.
[08:47:28][W][sml:116]: Checksum error in received SML data.
[08:47:29][W][sml:116]: Checksum error in received SML data.
[08:47:30][W][sml:116]: Checksum error in received SML data.
[08:47:31][W][sml:116]: Checksum error in received SML data.
[08:47:32][W][sml:116]: Checksum error in received SML data.
[08:47:33][W][sml:116]: Checksum error in received SML data.
[08:47:34][W][sml:116]: Checksum error in received SML data.
[08:47:35][W][sml:116]: Checksum error in received SML data.
[08:47:36][W][sml:116]: Checksum error in received SML data.
[08:47:37][W][sml:116]: Checksum error in received SML data.
[08:47:38][W][sml:116]: Checksum error in received SML data.
[08:47:39][W][sml:116]: Checksum error in received SML data.
[08:47:40][W][sml:116]: Checksum error in received SML data.
[08:47:41][W][sml:116]: Checksum error in received SML data.
[08:47:42][W][sml:116]: Checksum error in received SML data.
[08:47:43][W][sml:116]: Checksum error in received SML data.
[08:47:44][W][sml:116]: Checksum error in received SML data.
[08:47:45][W][sml:116]: Checksum error in received SML data.
[08:47:46][W][sml:116]: Checksum error in received SML data.
[08:47:47][W][sml:116]: Checksum error in received SML data.
[08:47:48][W][sml:116]: Checksum error in received SML data.
[08:47:49][W][sml:116]: Checksum error in received SML data.
[08:47:50][W][sml:116]: Checksum error in received SML data.
[08:47:51][W][sml:116]: Checksum error in received SML data.
[08:47:52][W][sml:116]: Checksum error in received SML data.
[08:47:53][W][sml:116]: Checksum error in received SML data.
[08:47:54][W][sml:116]: Checksum error in received SML data.
[08:47:55][W][sml:116]: Checksum error in received SML data.
[08:47:56][W][sml:116]: Checksum error in received SML data.
[08:47:57][W][sml:116]: Checksum error in received SML data.
[08:47:58][W][sml:116]: Checksum error in received SML data.
[08:47:59][W][sml:116]: Checksum error in received SML data.
[08:48:00][W][sml:116]: Checksum error in received SML data.
[08:48:01][W][sml:116]: Checksum error in received SML data.
[08:48:02][W][sml:116]: Checksum error in received SML data.
[08:48:03][W][sml:116]: Checksum error in received SML data.
[08:48:04][W][sml:116]: Checksum error in received SML data.
[08:48:05][W][sml:116]: Checksum error in received SML data.
[08:48:06][W][sml:116]: Checksum error in received SML data.
[08:48:07][W][sml:116]: Checksum error in received SML data.
[08:48:08][W][sml:116]: Checksum error in received SML data.
[08:48:09][W][sml:116]: Checksum error in received SML data.
[08:48:10][W][sml:116]: Checksum error in received SML data.
[08:48:11][W][sml:116]: Checksum error in received SML data.
[08:48:12][W][sml:116]: Checksum error in received SML data.
[08:48:13][W][sml:116]: Checksum error in received SML data.
[08:48:14][W][sml:116]: Checksum error in received SML data.
[08:48:15][W][sml:116]: Checksum error in received SML data.
[08:48:16][W][sml:116]: Checksum error in received SML data.
[08:48:17][W][sml:116]: Checksum error in received SML data.
[08:48:18][W][sml:116]: Checksum error in received SML data.
[08:48:19][W][sml:116]: Checksum error in received SML data.
[08:48:20][W][sml:116]: Checksum error in received SML data.
[08:48:21][W][sml:116]: Checksum error in received SML data.
[08:48:22][W][sml:116]: Checksum error in received SML data.
[08:48:23][W][sml:116]: Checksum error in received SML data.
[08:48:24][W][sml:116]: Checksum error in received SML data.
[08:48:25][W][sml:116]: Checksum error in received SML data.
[08:48:26][W][sml:116]: Checksum error in received SML data.
[08:48:27][W][sml:116]: Checksum error in received SML data.
[08:48:28][W][sml:116]: Checksum error in received SML data.
[08:48:29][W][sml:116]: Checksum error in received SML data.

Additional information

No response

@Lukel1412
Copy link

Lukel1412 commented Aug 17, 2023

Same problem here.

@saschaabraham
Copy link

saschaabraham commented Aug 17, 2023

Same here with German Smart Meter and IR Reader. Worked nearly 8 months without any issue. Now with 202308 nothing.

@Bascht74
Copy link

same here

@Bascht74
Copy link

Is there a way to go back just for the SML component?

@GLSSoftware
Copy link

GLSSoftware commented Aug 17, 2023

same problem here.
Possible cause: some meters do report valid negative values when a photovoltaic system is installed and electricity is fed in.
The change should be reverted.

@oliver507app
Copy link

same here after update

@GLSSoftware
Copy link

GLSSoftware commented Aug 17, 2023

Workaround posted here from @Skeletitor (thanks a lot):

#4805 (comment)

@alengwenus
Copy link

I think esphome/esphome#4798 is the one to blame. Unfortunately, I really don't know how to fix this besides reverting everything. Maybe @Mat931 can have a look?

@Mat931
Copy link

Mat931 commented Aug 17, 2023

Found the problem. I forgot to subtract 2 from the buffer length when calculating the checksum.

Can you add this to your config and try if it works?

external_components:
  - source: github://pr#5271
    components: [sml]
    refresh: always

@Skeletitor
Copy link

Found the problem. I forgot to subtract 2 from the buffer length when calculating the checksum.

Can you add this to your config and try if it works?

external_components:
  - source: github://pr#5271
    components: [sml]
    refresh: always

It works. Log output feels a bit slower. And there are some Warnings.

19:07:12 | [W] | [component:204] | Component sml took a long time for an operation (0.14 s).
19:07:12 | [W] | [component:205] | Components should block for at most 20-30ms.

@MrXermon
Copy link
Author

Found the problem. I forgot to subtract 2 from the buffer length when calculating the checksum.

Can you add this to your config and try if it works?

external_components:
  - source: github://pr#5271
    components: [sml]
    refresh: always

Seems to be working for me, too. I do not see any warnings on my end. Logging with level DEBUG is enabled.

@Skeletitor
Copy link

Seems to be working for me, too. I do not see any warnings on my end. Logging with level DEBUG is enabled.

Okay: I'll take a look at my config.
@Mat931 Good job and tank you very much!

@GLSSoftware
Copy link

GLSSoftware commented Aug 17, 2023

Thank you very much for fixing the issue!

19:07:12 | [W] | [component:204] | Component sml took a long time for an operation (0.14 s).
19:07:12 | [W] | [component:205] | Components should block for at most 20-30ms.

I also get these warnings. But I have them in other ESPHome components that do not use sml, too.
e.g.:

[19:29:20][W][component:204]: Component ssd1306_base took a long time for an operation (0.30 s).
[19:29:20][W][component:205]: Components should block for at most 20-30ms.

I would guess that these warnings do have some other cause.

@wtremmel
Copy link

Confirmed as well, works

@Mat931
Copy link

Mat931 commented Aug 17, 2023

The warnings might be because I changed the lookup table used in the CRC calculation to a smaller (512 bytes -> 64 bytes) but slightly slower one. This only affects the ESP8266 since the ESP32 has hardware acceleration for calculating CRCs.
If speed is really the problem we can change it back to the big lookup table.
If you see the warnings or not might also depend on how much data your meter sends.

@jesserockz
Copy link
Member

The PR fixing will be in 2023.8.1

@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.