SzczepanLeon / esphome-components

133 stars 43 forks source link

[V4.0] Crash on apatorna1, apator08, ... drivers. #125

Open kzajac83 opened 11 hours ago

kzajac83 commented 11 hours ago

Hello

New driver Apator NA-1 cause disconnect after processing msg.

In logs telegram from Apator NA-1 however disconnect occur after every telegram with correct CRC and build in apatorna1driver.

INFO ESPHome 2024.9.1
INFO Reading configuration /config/esphome/wmbus-reader.yaml...
INFO Updating https://github.com/SzczepanLeon/esphome-components.git@main
INFO Detected timezone 'Europe/Warsaw'
INFO Starting log output from 192.168.13.108 using esphome API
WARNING Can't connect to ESPHome API for wmbus-reader-v2 @ 192.168.13.108: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.168.13.108', port=6053))]: [Errno 111] Connect call failed ('192.168.13.108', 6053) (SocketAPIError)
INFO Trying to connect to wmbus-reader-v2 @ 192.168.13.108 in the background
INFO Successfully connected to wmbus-reader-v2 @ 192.168.13.108 in 0.013s
INFO Successful handshake with wmbus-reader-v2 @ 192.168.13.108 in 0.098s
[21:37:16][I][app:100]: ESPHome version 2024.9.1 compiled on Sep 23 2024, 21:11:58
[21:37:16][I][app:102]: Project esphome.wmbus_reader_v2 version 1.0
[21:37:16][C][status_led:019]: Status LED:
[21:37:16][C][status_led:020]:   Pin: GPIO15
[21:37:16][C][wifi:600]: WiFi:
[21:37:16][C][wifi:428]:   Local MAC: 80:65:99:E2:30:6C
[21:37:16][C][wifi:433]:   SSID: [redacted]
[21:37:16][C][wifi:436]:   IP Address: 192.168.13.108
[21:37:16][C][wifi:440]:   BSSID: [redacted]
[21:37:16][C][wifi:441]:   Hostname: 'wmbus-reader-v2'
[21:37:16][C][wifi:443]:   Signal strength: -76 dB ▂▄▆█
[21:37:16][V][wifi:445]:   Priority: 0.0
[21:37:16][C][wifi:447]:   Channel: 8
[21:37:16][C][wifi:448]:   Subnet: 255.255.255.0
[21:37:16][C][wifi:449]:   Gateway: 192.168.13.1
[21:37:16][C][wifi:450]:   DNS1: 0.0.0.0
[21:37:16][C][wifi:451]:   DNS2: 0.0.0.0
[21:37:16][C][logger:185]: Logger:
[21:37:16][C][logger:186]:   Level: VERBOSE
[21:37:16][C][logger:188]:   Log Baud Rate: 115200
[21:37:16][C][logger:189]:   Hardware UART: USB_CDC
[21:37:16][C][homeassistant.time:010]: Home Assistant Time:
[21:37:16][C][homeassistant.time:011]:   Timezone: 'CET-1CEST,M3.5.0,M10.5.0/3'
[21:37:16][C][mdns:116]: mDNS:
[21:37:16][C][mdns:117]:   Hostname: wmbus-reader-v2
[21:37:16][V][mdns:118]:   Services:
[21:37:16][V][mdns:120]:   - _esphomelib, _tcp, 6053
[21:37:16][V][mdns:122]:     TXT: friendly_name = wmbus reader v2
[21:37:16][V][mdns:122]:     TXT: version = 2024.9.1
[21:37:16][V][mdns:122]:     TXT: mac = 806599e2306c
[21:37:16][V][mdns:122]:     TXT: platform = ESP32
[21:37:16][V][mdns:122]:     TXT: board = lolin_s2_mini
[21:37:16][V][mdns:122]:     TXT: network = wifi
[21:37:16][V][mdns:122]:     TXT: api_encryption = Noise_NNpsk0_25519_ChaChaPoly_SHA256
[21:37:16][V][mdns:122]:     TXT: project_name = esphome.wmbus_reader_v2
[21:37:16][V][mdns:122]:     TXT: project_version = 1.0
[21:37:16][V][mdns:122]:     TXT: package_import_url = github://MariuszWoszczynski/wmbus-reader-v2/wmbus-reader-v2.yaml@main?full_config
[21:37:16][C][esphome.ota:073]: Over-The-Air updates:
[21:37:16][C][esphome.ota:074]:   Address: 192.168.13.108:3232
[21:37:16][C][esphome.ota:075]:   Version: 2
[21:37:16][C][safe_mode:018]: Safe Mode:
[21:37:16][C][safe_mode:020]:   Boot considered successful after 60 seconds
[21:37:16][C][safe_mode:021]:   Invoke after 10 boot attempts
[21:37:16][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[21:37:16][C][api:139]: API Server:
[21:37:16][C][api:140]:   Address: 192.168.13.108:6053
[21:37:16][C][api:142]:   Using noise encryption: YES
[21:37:16][C][wmbus:297]: wM-Bus v4.0.1-1.17.1:
[21:37:16][C][wmbus:314]:   MAC: E2996580
[21:37:16][C][wmbus:315]:   CC1101 frequency: 868.950 MHz
[21:37:16][C][wmbus:316]:   CC1101 SPI bus:
[21:37:16][C][wmbus:320]:     MOSI Pin: GPIO35
[21:37:16][C][wmbus:321]:     MISO Pin: GPIO37
[21:37:16][C][wmbus:322]:     CLK Pin:  GPIO36
[21:37:16][C][wmbus:323]:     CS Pin:   GPIO34
[21:37:16][C][wmbus:324]:     GDO0 Pin: GPIO2
[21:37:16][C][wmbus:325]:     GDO2 Pin: GPIO1
[21:37:16][C][wmbus:331]:   Available drivers: hydrocalm3, apatorna1
[21:37:16][C][wmbus:345]:   Meter:
[21:37:16][C][wmbus:346]:     ID: 76625281 [0x04913581]
[21:37:16][C][wmbus:347]:     Type: apatorna1
[21:37:16][C][wmbus:348]:     Key: ''
[21:37:16][C][wmbus:350]:     Field: 'total'
[21:37:16][C][wmbus:351]:      Name: 'cold water from Apator NA-1'
[21:37:16][C][wmbus:351]:        Device Class: 'water'
[21:37:16][C][wmbus:351]:        State Class: 'total_increasing'
[21:37:16][C][wmbus:351]:        Unit of Measurement: 'm³'
[21:37:16][C][wmbus:351]:        Accuracy Decimals: 3
[21:37:16][C][wmbus:351]:        Icon: 'mdi:water'
[21:37:16][C][wmbus:345]:   Meter:
[21:37:16][C][wmbus:346]:     ID: 85098561 [0x05128041]
[21:37:16][C][wmbus:347]:     Type: hydrocalm3
[21:37:16][C][wmbus:348]:     Key: ''
[21:37:16][C][wmbus:350]:     Field: 'rssi'
[21:37:16][C][wmbus:351]:      Name: 'HYDROCAL rssi'
[21:37:16][C][wmbus:351]:        Device Class: 'signal_strength'
[21:37:16][C][wmbus:351]:        State Class: 'measurement'
[21:37:16][C][wmbus:351]:        Unit of Measurement: 'dBm'
[21:37:16][C][wmbus:351]:        Accuracy Decimals: 0
[21:37:16][C][wmbus:350]:     Field: 'total_heating'
[21:37:16][C][wmbus:351]:      Name: 'HYDROCAL m3'
[21:37:16][C][wmbus:351]:        Device Class: 'water'
[21:37:16][C][wmbus:351]:        State Class: 'total_increasing'
[21:37:16][C][wmbus:351]:        Unit of Measurement: 'm³'
[21:37:16][C][wmbus:351]:        Accuracy Decimals: 3
[21:38:49][V][rxLoop:167]: Have 53 bytes from CC1101 Rx, RSSI: -56 dBm LQI: 128
[21:38:49][V][rxLoop:172]: Synchronus mode enabled.
[21:38:49][D][mbus:035]: Received T1 A frame
[21:38:49][V][mbus:046]: Frame: 37471C58D59AB0D2D994D59C35C5935B134D9962D958DD13C4D5B4C56B0E8CE71637295394D4D9B13C74D264E38D668D9565B1D310 (53) [RAW]
[21:38:49][V][mbus:053]: Frame: 1C4401068135910414070D11A03501C7D10CD082B2401E97917587DCCA7BB061900DCD (35) [with CRC]
[21:38:49][V][mbus:096]: Validating CRC for Block1
[21:38:49][V][crc:031]:     calculated: 0x0D11, read: 0x0D11
[21:38:49][V][mbus:116]: Validating CRC for Block2
[21:38:49][V][crc:031]:     calculated: 0xCA7B, read: 0xCA7B
[21:38:49][V][mbus:116]: Validating CRC for Block3
[21:38:49][V][crc:031]:     calculated: 0x0DCD, read: 0x0DCD
[21:38:49][V][mbus:063]: Frame: 1C440106813591041407A03501C7D10CD082B2401E97917587DCB06190 (29) [without CRC]
[21:38:49][V][Telegram.cpp:1131]: (wmbus) parseDLL @0 29
[21:38:49][V][Telegram.cpp:1178]: (wmbus) parseELL @10 19
[21:38:49][V][Telegram.cpp:1333]: (wmbus) parseNWL @10 19
[21:38:49][V][Telegram.cpp:1391]: (wmbus) parseAFL @10 19
[21:38:49][V][Telegram.cpp:2078]: (wmbus) parseTPL @10 19
WARNING wmbus-reader-v2 @ 192.168.13.108: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for wmbus-reader-v2 @ 192.168.13.108
WARNING Disconnected from API
INFO Successfully connected to wmbus-reader-v2 @ 192.168.13.108 in 0.008s
INFO Successful handshake with wmbus-reader-v2 @ 192.168.13.108 in 5.354s
WARNING wmbus-reader-v2 @ 192.168.13.108: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for wmbus-reader-v2 @ 192.168.13.108
WARNING Disconnected from API
WARNING Can't connect to ESPHome API for wmbus-reader-v2 @ 192.168.13.108: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.168.13.108', port=6053))]: [Errno 111] Connect call failed ('192.168.13.108', 6053) (SocketAPIError)
INFO Trying to connect to wmbus-reader-v2 @ 192.168.13.108 in the background

YAML


dashboard_import:
  package_import_url: github://MariuszWoszczynski/wmbus-reader-v2/wmbus-reader-v2.yaml@main
  import_full_config: true

substitutions:
  name: "wmbus-reader-v2"
  friendly_name: "wmbus reader v2"
  status_led: GPIO15

esphome:
  name: "${name}"
  friendly_name: "${friendly_name}"
  project:
    name: esphome.wmbus_reader_v2
    version: "1.0"

esp32:
  board: lolin_s2_mini
  framework:
    type: arduino

external_components:
  - source: github://SzczepanLeon/esphome-components@main
    components: [ wmbus ]
    refresh: 0d

#time:
# - platform: sntp
#   id: time_sntp

time:
#  - platform: sntp
#    id: sntp_time
#    timezone: Europe/Warsaw
#    - servers:
#      0.pool.ntp.org
#      1.pool.ntp.org
#      2.pool.ntp.org
  #platform: sntp
  #servers: 192.168.13.1 
  #id: time_sntp
   platform: homeassistant
   id: homeassistant_time
#   timezone: Europe/Warsaw 

# Enable logging
logger:
  id: component_logger
  level: VERBOSE #DEBUG #INFO #

# Enable Home Assistant API
api:
  encryption:
    key: "D0KKR80TBX3z2sx+Pejf1BBJ/+jaj5dQZXNZuwD/s8k="

ota:
 - platform: esphome

wifi:
  power_save_mode: none #LIGHT
  reboot_timeout: 10min
  output_power: 18dB
  #fast_connect: true
  networks:
  - ssid: "SSID_1"
    password: "PASSWD_1"

    #  static IP configuration (instead of data from the secret file)
    manual_ip:
      static_ip: 192.168.13.108
      gateway: 192.168.13.1
      subnet: 255.255.255.0
  - ssid: "SSID_2"
    password: "PASSWD_2"
    #fast_connect: true

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "WMBUS Reader v2"

# Status LED for connection
status_led:
  pin:
    # Blue LED
    number: ${status_led}

#captive_portal:

#web_server: 
#  port: 80

wmbus:
  mosi_pin: GPIO35
  clk_pin:  GPIO36 
  miso_pin: GPIO37
  gdo2_pin: GPIO1 
  gdo0_pin: GPIO2
  cs_pin:   GPIO34
  #log_unknown: true
  log_all: False
  all_drivers: False
  sync_mode: true

sensor:
  - platform: wmbus
    meter_id: 0x05128041
    type: hydrocalm3
    #key: "00000000000000000000000000000000"
    sensors:
      - name: "HYDROCAL rssi"
        field: "rssi"
        accuracy_decimals: 0
        unit_of_measurement: "dBm"
        device_class: "signal_strength"
        state_class: "measurement"
        entity_category: "diagnostic"
      - name: "HYDROCAL total kWh"
        field: "total_heating"
        accuracy_decimals: 3
        unit_of_measurement: "kwh"
        device_class: "energy"
        state_class: "total_increasing"
      - name: "HYDROCAL m3"
        field: "total_heating"
        accuracy_decimals: 3
        unit_of_measurement: "m³"
        device_class: "water"
        state_class: "total_increasing"
  - platform: wmbus
    meter_id: 0x04913581
    type: apatorna1
    sensors:
      - name: "cold water from Apator NA-1"
        field: "total"
        accuracy_decimals: 3
        unit_of_measurement: "m³"
        device_class: "water"
        state_class: "total_increasing"
        icon: "mdi:water"
        # filters:
        #   - offset: 123.0
czesiu20 commented 10 hours ago

Hello, the same for apator08.

Everytime a frame from apator08 is received my ESP device crashes.

[21:31:36][V][Telegram.cpp:1131]: (wmbus) parseDLL  @0103
[21:31:36][V][Telegram.cpp:1178]: (wmbus) parseELL @10 93
[21:31:36][V][Telegram.cpp:1333]: (wmbus) parseNWL @10 93
WARNING wmbus-reader @ 10.0.0.135: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for wmbus-reader @ 10.0.0.135
WARNING Disconnected from API
INFO Successfully connected to wmbus-reader @ 10.0.0.135 in 0.116s
INFO Successful handshake with wmbus-reader @ 10.0.0.135 in 0.091s
[21:32:14][D][api:102]: Accepted 10.0.0.200
[21:32:14][V][api.connection:1427]: Hello from client: 'Home Assistant 2024.9.2' | 10.0.0.200 | API Version 1.10

Full log attached: logs_wmbus-reader_run.txt

I can see and decode the fame from the log:

{
    "media":"water",
    "meter":"apator08",
    "name":"",
    "id":"000b9ce7",
    "total_m3":61.097,
    "timestamp":"2024-09-23T19:12:48Z"
}

Other device unismart is working well: obraz

I removed configuration for apator08 and compiled, with no luck. Then, I removed configuration for unismart, it didn't help. At this stage only configuration of wmbus left, no sensors configured, still crashes. Finally, I commented out configuration for wmbus and the hang-ups have stopped.

I reverted to version 3 where everything is OK.

kzajac83 commented 10 hours ago

Well, seems you have right. Stay only hydroclima3driver in my cause:

[22:21:33][C][wmbus:331]: Available drivers: hydrocalm3

and again the same

22:24:02][D][api.connection:1445]: Home Assistant 2024.9.2 (192.168.15.20): Connected successfully
[22:24:02][D][time:051]: Synchronized time: 2024-09-23 22:24:02
[22:24:05][D][mbus:035]: Received T1 A frame
WARNING wmbus-reader-v2 @ 192.168.13.108: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for wmbus-reader-v2 @ 192.168.13.108
WARNING Disconnected from API
WARNING Can't connect to ESPHome API for wmbus-reader-v2 @ 192.168.13.108: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.168.13.108', port=6053))]: [Errno 111] Connect call failed ('192.168.13.108', 6053) (SocketAPIError)
INFO Trying to connect to wmbus-reader-v2 @ 192.168.13.108 in the background

So problem is bigger in V4.0

SzczepanLeon commented 10 hours ago

Please try

external_components:
  - source: github://SzczepanLeon/esphome-components@ana1
    components: [ wmbus ]
    refresh: 0d
kzajac83 commented 10 hours ago
INFO ESPHome 2024.9.1
INFO Reading configuration /config/esphome/wmbus-reader.yaml...
INFO Updating https://github.com/SzczepanLeon/esphome-components.git@ana1

...
....
....

[D][mbus:035]: Received T1 A frame
[V][mbus:046]: Frame: 6B271C58D59A3A5396B0E59659959366CD0B4E665A596696B19956B1998B94B38DD1A713C934CD66C94ECA36533724D3C5A98E3B1C9A69334E71A3A9D344ECCA64D398E9A5993B0B70B5A935AC9AC6969AB315AC2D99A659C5ACA56C4D38D6A673138BA71C4DA7438BA6C2E658D353D31A74A69C93A5CC665B23B4C59732C9638D2E394D6634CB8D9D1C69AD19693C59CA64F42E66A335C4EC723A72C4ED2558E2D9C533ACC4D65CA655B24CD59996336C369D0B4CD369C4DCA63964D370B5 (191) [RAW]
[V][mbus:053]: Frame: 6E44010629208200050758C37A560060859085A39321C647E7715892EB571E77D6A22DE66712462FCC78EA77A2A9A783430F16E6DF668D0835AA0408F0D1216A4D23FDD1FC23F83A0117CDFCFFE7F4DA0E2CD54EE0213B915B73B5C466C567D5EA7C3A6B14784BFED2C90235D728D154F90E71059B181FC3711FD1EA207743 (127) [with CRC]
[V][mbus:096]: Validating CRC for Block1
[V][crc:031]:     calculated: 0x58C3, read: 0x58C3
[V][mbus:116]: Validating CRC for Block2
[V][crc:031]:     calculated: 0xEB57, read: 0xEB57
[V][mbus:116]: Validating CRC for Block3
[V][crc:031]:     calculated: 0xA783, read: 0xA783
[V][mbus:116]: Validating CRC for Block4
[V][crc:031]:     calculated: 0x4D23, read: 0x4D23
[V][mbus:116]: Validating CRC for Block5
[V][crc:031]:     calculated: 0xD54E, read: 0xD54E
[V][mbus:116]: Validating CRC for Block6
[V][crc:031]:     calculated: 0x1478, read: 0x1478
[V][mbus:116]: Validating CRC for Block7
[V][crc:031]:     calculated: 0x1FC3, read: 0x1FC3
[V][mbus:116]: Validating CRC for Block8
[V][crc:031]:     calculated: 0x7743, read: 0x7743
[V][mbus:063]: Frame: 6E4401062920820005077A560060859085A39321C647E77158921E77D6A22DE66712462FCC78EA77A2A9430F16E6DF668D0835AA0408F0D1216AFDD1FC23F83A0117CDFCFFE7F4DA0E2CE0213B915B73B5C466C567D5EA7C3A6B4BFED2C90235D728D154F90E71059B18711FD1EA20 (111) [without CRC]
[V][Telegram.cpp:1131]: (wmbus) parseDLL @0 111
[V][Telegram.cpp:1178]: (wmbus) parseELL @10 101
[V][Telegram.cpp:1333]: (wmbus) parseNWL @10 101
[V][Telegram.cpp:1391]: (wmbus) parseAFL @10 101
[V][Telegram.cpp:2078]: (wmbus) parseTPL @10 101
[V][wmbus:063]: 01 - header przeparsowany
[V][wmbus:066]: 02 - driver wybrany

And disconnect:

image

After some time appear


WARNING wmbus-reader-v2 @ 192.168.13.108: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for wmbus-reader-v2 @ 192.168.13.108
WARNING Disconnected from API
INFO Successfully connected to wmbus-reader-v2 @ 192.168.13.108 in 0.014s
INFO Successful handshake with wmbus-reader-v2 @ 192.168.13.108 in 0.096s
SzczepanLeon commented 10 hours ago

the same for apator08.

@czesiu20 but on what HW? Please share full YAML.

czesiu20 commented 8 hours ago

HW is nodemcu esp32 and cc1101 from Mariusz Woszczynski.

My YAML:

substitutions:
  name: "wmbus-reader"
  friendly_name: "wmbus-reader"

esphome:
  name: "${name}"
  friendly_name: "${friendly_name}"
  project:
    name: esphome.wmbus_reader
    version: "1.0"
  # only for RPI 
  compile_process_limit: 1  

esp32:
  board: esp32dev
  framework:
    type: arduino

external_components:
  - source: github://SzczepanLeon/esphome-components@main
    components: [ wmbus ]
    refresh: 0d

time:
 - platform: sntp
   id: time_sntp

# Enable logging
logger:
  level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_key

ota:
  platform: esphome
  password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none
  fast_connect: true
  reboot_timeout: 10min
  manual_ip:
    static_ip: 10.0.0.135
    gateway: 10.0.0.1
    subnet: 255.255.255.0

web_server: 
  port: 80

wmbus:
  mosi_pin: GPIO32
  clk_pin:  GPIO33 
  miso_pin: GPIO19
  gdo2_pin: GPIO21
  gdo0_pin: GPIO22
  cs_pin:   GPIO23

  led_pin: GPIO2
  led_blink_time: "1s"

sensor:
  - platform: wmbus
    meter_id: 0x000ABFA4
    type: apator08
    sensors:
    - field: "rssi"
      name: "Woda - Licznik główny - RSSI"
      accuracy_decimals: 0
      unit_of_measurement: "dBm"
      device_class: "signal_strength"
      state_class: "measurement"
      entity_category: "diagnostic"
    - field: "total"
      id: "woda_licznik_glowny"
      name: "Woda - Licznik główny"
      icon: "mdi:water"
      accuracy_decimals: 3
      unit_of_measurement: "m3"
      device_class: "water"
      state_class: "total_increasing"
      filters:
        - offset: 83.078
  - platform: wmbus
    meter_id: 0x000B9CE7
    type: apator08
    sensors:
    - field: "rssi"
      name: "Woda - Licznik ogrodowy - RSSI"
      accuracy_decimals: 0
      unit_of_measurement: "dBm"
      device_class: "signal_strength"
      state_class: "measurement"
      entity_category: "diagnostic"
    - field: "total"
      id: "woda_licznik_ogrodowy"
      name: "Woda - Licznik ogrodowy"
      icon: "mdi:water"
      accuracy_decimals: 3
      unit_of_measurement: "m3"
      device_class: "water"
      state_class: "total_increasing"
      filters:
        - offset: 60.457
  - platform: wmbus
    meter_id: 0x00058794
    type: unismart
    key: "00000000000000000000000000000000"
    sensors:
    - field: "rssi"
      name: "Licznik gazu - RSSI"
      accuracy_decimals: 0
      unit_of_measurement: "dBm"
      device_class: "signal_strength"
      state_class: "measurement"
      entity_category: "diagnostic"
    - field: "total"
      id: "licznik_gazu"
      name: "Licznik gazu"
      icon: "mdi:gas-burner"
      accuracy_decimals: 3
      unit_of_measurement: "m3"
      device_class: "gas"
      state_class: "total_increasing"
      filters:
        - offset: 4337.090
SzczepanLeon commented 2 hours ago

Seems that crash is somewhere below:


        bool supported_link_mode{false};
        if (drv_info.linkModes().empty()) {
          supported_link_mode = true;
... ... ...