Odczyt z licznika Kaifa MA309M po WMBUS, CC1101, biblioteka SzczepanLeon

Cześć.

Słuchajcie, bo walczę już 5 dzień i poległem.

Licznik prądu od Taurona KAIFA MA309M, włączona sień HAN. Mam klucz deszyfrujący. Kupiłem ESP32 + CC1101 868 MHz (zielona płytka). Stworzyłemn program dla ESPHome. Skończyło się na tym, że odbiera mi ramki z licznika, ale ich nie dekoduje. Encje są nieznane.

esphome:
  name: esphome-web-3fc1cc
  friendly_name: ESPHome Web 3fc1cc
  min_version: 2026.4.0
  name_add_mac_suffix: false

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:
  level: VERY_VERBOSE
    
api:

ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

time:
  - platform: sntp
    id: sntp_time

external_components:
  - source: github://SzczepanLeon/esphome-components@main
    components: [ wmbus_common, wmbus_meter, wmbus_radio ]

spi:
  id: my_spi
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

wmbus_common:

wmbus_radio:
  - id: cc1101_radio
    radio_type: cc1101
    spi_id: my_spi
    cs_pin: GPIO5
    frequency: 868.95MHz
    irq_pin:
      number: GPIO27
      mode:
        input: true
        pulldown: true

wmbus_meter:
  - id: tauron_meter
    meter_id: 40138424
    type: amiplus
    mode: Any
    key: "82D1905DDC57B603B88DA1F0D2362546"

sensor:
  - platform: wmbus_meter
    parent_id: tauron_meter
    field: total_energy_consumption
    name: "Tauron - Zużycie całkowite"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: total_energy_production
    name: "Tauron - Oddanie całkowite"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: energy_consumption_t1
    name: "Tauron - Zużycie Taryfa 1 (T1)"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: energy_consumption_t2
    name: "Tauron - Zużycie Taryfa 2 (T2)"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: power
    name: "Tauron - Moc pobierana"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: power_production
    name: "Tauron - Moc oddawana"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: power_l1
    name: "Tauron - Moc L1"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: power_l2
    name: "Tauron - Moc L2"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: power_l3
    name: "Tauron - Moc L3"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: voltage_l1
    name: "Tauron - Napięcie L1"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: voltage_l2
    name: "Tauron - Napięcie L2"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: voltage_l3
    name: "Tauron - Napięcie L3"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: current_l1
    name: "Tauron - Prąd L1"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: current_l2
    name: "Tauron - Prąd L2"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: current_l3
    name: "Tauron - Prąd L3"

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: rssi
    name: "Tauron - Siła sygnału wMBus"

Fragment z logów:

 
[12:28:01.394][D][wmbusmeters:351]: (wmbus) trimming frame A "6E44CD2C248413402C02FABF7A300060259033F9E3043B1F61EC977966A5C614BFBFCB28E5F3239647314392B1F8BCAC5F1534E41BC6C717BCBE00AC820C571A6AFCF15D7B552400BA019930332616A123508EA0F219B541FB2AAD8BCB1A67DAD3289FBDD0D763D7639884AFA867C12B13DAC8CE0B5922CEBB97E38F0A14C1"
[12:28:01.417][V][wmbusmeters:4933]: (wmbus) trimmed 16 dll crc bytes from frame a and ignored 0 suffix bytes.
[12:28:01.420][D][wmbusmeters:351]: (wmbus) trimmed frame A "6E44CD2C248413402C027A300060259033F9E3043B1F61EC9779C614BFBFCB28E5F3239647314392B1F85F1534E41BC6C717BCBE00AC820C571AF15D7B552400BA019930332616A12350F219B541FB2AAD8BCB1A67DAD3289FBD63D7639884AFA867C12B13DAC8CE0B59BB97E38F0A"
[12:28:01.450][D][wmbusmeters:351]: (wmbus) checkWMBUSFrame "6E44CD2C248413402C027A300060259033F9E3043B1F61EC9779C614BFBFCB28E5F3239647314392B1F85F1534E41BC6C717BCBE00AC820C571AF15D7B552400BA019930332616A12350F219B541FB2AAD8BCB1A67DAD3289FBD63D7639884AFA867C12B13DAC8CE0B59BB97E38F0A"
[12:28:01.471][V][wmbusmeters:5114]: (wmbus) received full frame.
[12:28:01.477][V][wmbus:054]: Have data (111 bytes) [RSSI: -70dBm, mode: T1 A]
[12:28:01.486][V][wmbusmeters:1066]: (wmbus) parseDLL @0 111
[12:28:01.510][V][wmbusmeters:1137]: (wmbus) parseELL @10 101
[12:28:01.511][V][wmbusmeters:1302]: (wmbus) parseNWL @10 101
[12:28:01.513][V][wmbusmeters:1333]: (wmbus) parseAFL @10 101
[12:28:01.517][V][wmbusmeters:2044]: (wmbus) parseTPL @10 101
[12:28:01.521][V][wmbusmeters:555]: (meter) amiplus-026476b8: for me? 40138424.M=KFM.V=2c.T=02 in 026476b8
[12:28:01.528][V][wmbusmeters:564]: (meter) amiplus-026476b8: not for me: no match
[12:28:01.538][W][wmbus:065]: Telegram not handled by any handler
[12:28:01.543][V][wmbusmeters:1066]: (wmbus) parseDLL @0 111
[12:28:01.543][V][wmbusmeters:1137]: (wmbus) parseELL @10 101
[12:28:01.543][V][wmbusmeters:1302]: (wmbus) parseNWL @10 101
[12:28:01.549][V][wmbusmeters:1333]: (wmbus) parseAFL @10 101
[12:28:01.560][V][wmbusmeters:2044]: (wmbus) parseTPL @10 101
[12:28:01.564][W][wmbus:070]: Check if telegram with address 40138424 can be parsed on:
[12:28:01.573][W][wmbus:073]: https://wmbusmeters.org/analyze/6e44cd2c248413402c027a300060259033f9e3043b1f61ec9779c614bfbfcb28e5f3239647314392b1f85f1534e41bc6c717bcbe00ac820c571af15d7b552400ba019930332616a12350f219b541fb2aad8bcb1a67dad3289fbd63d7639884afa867c12b13dac8ce0b59bb97e38f0a
[12:28:01.594][VV][component:212]: logger loop disabled
[12:28:12.221][VV][app:488]: logger loop enabled from ISR
[12:28:12.226][V][packet:082][radio_recv]: expected_size: 8
[12:28:12.227][VV][CC1101:240][radio_recv]: Restarting RX
[12:28:12.229][V][wmbus:116][radio_recv]: Queue items: 1
[12:28:12.230][V][wmbus:118][radio_recv]: Queue send success
[12:28:12.230][D][packet:106]: Have data from radio (8 bytes)
[12:28:12.230][D][wmbusmeters:351]: raw packet "EA975E9F22587DE6"
[12:28:12.233][V][packet:082]: expected_size: 8
[12:28:12.245][V][wmbusmeters:4857]: (wmbus) not enough bytes! expected at least 12 but got (8)!
[12:28:12.252][VV][component:212]: logger loop disabled

Probowałem zdekodować ramkę na wmbusmeters.org i wyszło coś takiego:



Jakieś sugestie? Dlaczego ESPHome mi tego nie dekoduje i encje mają stan nieznany.

esphome:
  name: esphome-web-3fc1cc
  friendly_name: ESPHome Web 3fc1cc
  min_version: 2026.4.0
  name_add_mac_suffix: false

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:
  level: DEBUG          # VERY_VERBOSE tylko do diagnozy, na stałe zabija wydajność

api:

ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

time:
  - platform: sntp
    id: sntp_time

external_components:
  - source: github://SzczepanLeon/esphome-components@main
    components: [ wmbus_common, wmbus_meter, wmbus_radio ]

spi:
  id: my_spi
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

wmbus_common:
  drivers:
    - amiplus

wmbus_radio:
  - id: cc1101_radio
    radio_type: cc1101
    spi_id: my_spi
    cs_pin: GPIO5
    frequency: 868.95MHz
    irq_pin:
      number: GPIO27
      mode:
        input: true
        pulldown: true

wmbus_meter:
  - id: tauron_meter
    meter_id: "0x40138424"        # BYŁO: 40138424 → YAML czytał to dziesiętnie = 0x026476B8
    type: amiplus
    key: !secret tauron_key       # klucz przenieś do secrets.yaml
    mode:
      - T1

sensor:
  - platform: wmbus_meter
    parent_id: tauron_meter
    field: total_energy_consumption_kwh
    name: "Tauron - Zużycie całkowite"
    unit_of_measurement: "kWh"
    accuracy_decimals: 3
    device_class: energy
    state_class: total_increasing

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: total_energy_production_kwh
    name: "Tauron - Oddanie całkowite"
    unit_of_measurement: "kWh"
    accuracy_decimals: 3
    device_class: energy
    state_class: total_increasing

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: current_power_consumption_kw
    name: "Tauron - Moc pobierana"
    unit_of_measurement: "kW"
    accuracy_decimals: 3
    device_class: power
    state_class: measurement

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: current_power_production_kw
    name: "Tauron - Moc oddawana"
    unit_of_measurement: "kW"
    accuracy_decimals: 3
    device_class: power
    state_class: measurement

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: voltage_at_phase_1_v
    name: "Tauron - Napięcie L1"
    unit_of_measurement: "V"
    accuracy_decimals: 0
    device_class: voltage
    state_class: measurement

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: voltage_at_phase_2_v
    name: "Tauron - Napięcie L2"
    unit_of_measurement: "V"
    accuracy_decimals: 0
    device_class: voltage
    state_class: measurement

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: voltage_at_phase_3_v
    name: "Tauron - Napięcie L3"
    unit_of_measurement: "V"
    accuracy_decimals: 0
    device_class: voltage
    state_class: measurement

  - platform: wmbus_meter
    parent_id: tauron_meter
    field: rssi_dbm
    name: "Tauron - Siła sygnału wMBus"
    unit_of_measurement: "dBm"
    accuracy_decimals: 0
    device_class: signal_strength
    state_class: measurement
    entity_category: diagnostic

text_sensor:
  - platform: wmbus_meter
    parent_id: tauron_meter
    field: device_datetime
    name: "Tauron - Zegar licznika"

Po zaproponowanych zmianach nie łapie ramek z Tauron. Tylko te ramki 8 bajtów wykrywa. Po za tym mam wtedy błędy w logach:

[19:58:01.249][W][CC1101:278][radio_recv]: RX FIFO overflow

Edit:
Próbowałem również wersję z moim kodem i zamienić tylko sensory, na te co kolega powyżej proponuje, ale efekt jest niezmienny. Ramki z Tauron wykrywa, a encje stan “nieznany”.


Spróbuj wpisać ID licznika z zamienioną kolejnością bajtów. Mi Tauron na stroje podaje eLicznika podaje adres 43240000, a musiałem wpisać meter_id: “00002443”. Tylko że ja korzystam z IoTlabs, ale to prawie to samo.

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    meter_id: "0x40138424"

I tyle ma poprawić plus to co dałem wcześniej.

Dzięki. Pomogło. Kluczem były encje i wpis:
meter_id: 0x40138424