Skip to content

Various startup errors when setting up electrical measurement and metering cluster #27

@papylhomme

Description

@papylhomme

Hello,

I'm trying to set up reporting from a PZEM-004T sensor using zigbee. After digging into the ZCL specs I came up with this config, and it's more or less working.

Working ✅

voltage, power and current are exposed in Z2M, read command works, reporting works too

Image

Image

Almost Working 👷

For frequency, read command and reporting works, but somehow the sensor is not directly exposed in Z2M 🤷 If you get any idea about this, otherwise I can live without it.

Expose is missing frequency...
Image

...but reading frequency is working:
Image

Not really working 🚧

For Current Summation Delivered it's not working so easily

Sensor is exposed with no associated value...
Image

...but I can read the value using a command ✅
Image

Z2M complains about missing attributes in the metering cluster when configuring the device, and also querying them directly (divisor/multiplier), although they are present in the config (see below)

Image

Unable to configure reporting with the error "UNREPORTABLE_ATTRIBUTE". This is clearly not quite true, I checked other zigbee appliance and they have reporting enabled for this attribute (Adeo SIN-4-FP-21_EQU, Nous A1Z)
Image

TODO

Better control with formatting, right now I'm missing some decimals.

Startup errors

  • I can see there is an ESP_FAIL error when adding seMetering divisor and multiplier attribute (0x301 and 0x302) => Explain the error in Z2M
  • Many "ESP_ZIGBEE_ATTRIBUTE: The requested update attribute is not found"
  • For each cluster "ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x508 is not found"

Here is the output when starting the device :

INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyACM0 with baud rate 115200
[22:27:02]Vj
[22:27:02]load:0x408460e8,len:0x1778
[22:27:02]entry 0x4083cfd0
[22:27:02]I (23) boot: ESP-IDF 5.1.5 2nd stage bootloader
[22:27:02]I (24) boot: compile time Jan 24 2025 18:53:23
[22:27:02]I (25) boot: chip revision: v0.1
[22:27:02]I (26) boot.esp32h2: SPI Speed      : 64MHz
[22:27:02]I (31) boot.esp32h2: SPI Mode       : DIO
[22:27:02]I (36) boot.esp32h2: SPI Flash Size : 4MB
[22:27:02]I (41) boot: Enabling RNG early entropy source...
[22:27:02]I (46) boot: Partition Table:
[22:27:02]I (50) boot: ## Label            Usage          Type ST Offset   Length
[22:27:02]I (57) boot:  0 otadata          OTA data         01 00 00009000 00002000
[22:27:02]I (64) boot:  1 phy_init         RF data          01 01 0000b000 00001000
[22:27:02]I (72) boot:  2 app0             OTA app          00 10 00010000 001b0000
[22:27:02]I (79) boot:  3 app1             OTA app          00 11 001c0000 001b0000
[22:27:02]I (87) boot:  4 nvs              WiFi data        01 02 00370000 0006d000
[22:27:02]I (94) boot:  5 zb_storage       Unknown data     01 81 003dd000 00004000
[22:27:02]I (102) boot:  6 zb_fct           Unknown data     01 81 003e1000 00000400
[22:27:02]I (109) boot: End of partition table
[22:27:02]I (114) boot: No factory image, trying OTA 0
[22:27:02]I (119) esp_image: segment 0: paddr=00010020 vaddr=42080020 size=12060h ( 73824) map
[22:27:02]I (150) esp_image: segment 1: paddr=00022088 vaddr=40800000 size=0b0d4h ( 45268) load
[22:27:02]I (166) esp_image: segment 2: paddr=0002d164 vaddr=4080b0e0 size=01af4h (  6900) load
[22:27:02]I (169) esp_image: segment 3: paddr=0002ec60 vaddr=00000000 size=013b8h (  5048) 
[22:27:02]I (173) esp_image: segment 4: paddr=00030020 vaddr=42000020 size=7b65ch (505436) map
[22:27:02]I (337) boot: Loaded app from partition at offset 0x10000
[22:27:02]I (359) boot: Set actual ota_seq=1 in otadata[0]
[22:27:02]I (360) boot: Disabling RNG early entropy source...
[22:27:02]I (370) cpu_start: Unicore app
[22:27:02]I (371) cpu_start: Pro cpu up.
[22:27:03]W (379) clk: esp_perip_clk_init() has not been implemented yet
[22:27:03]I (386) cpu_start: Pro cpu start user code
[22:27:03]I (386) cpu_start: cpu freq: 96000000 Hz
[22:27:03]I (387) cpu_start: Application information:
[22:27:03]I (389) cpu_start: Project name:     esp-h2-power-monitoring-1
[22:27:03]I (395) cpu_start: App version:      2024.12.2
[22:27:03]I (400) cpu_start: Compile time:     Jan 24 2025 18:53:11
[22:27:03]I (406) cpu_start: ELF file SHA256:  0ad08a3b047a5c5d...
[22:27:03]I (412) cpu_start: ESP-IDF:          5.1.5
[22:27:03]I (417) cpu_start: Min chip rev:     v0.0
[22:27:03]I (422) cpu_start: Max chip rev:     v0.99 
[22:27:03]I (427) cpu_start: Chip rev:         v0.1
[22:27:03]I (432) heap_init: Initializing. RAM available for dynamic allocation:
[22:27:03]I (439) heap_init: At 408115E0 len 0003BDA0 (239 KiB): D/IRAM
[22:27:03]I (445) heap_init: At 4084D380 len 00002B60 (10 KiB): STACK/DIRAM
[22:27:03]I (453) spi_flash: detected chip: generic
[22:27:03]I (457) spi_flash: flash io: dio
[22:27:03]I (461) sleep: Configure to isolate all GPIO pins in sleep state
[22:27:03]I (467) sleep: Enable automatic switching of GPIO sleep configuration
[22:27:03]I (475) app_start: Starting scheduler on CPU0
[22:27:03]I (479) main_task: Started on CPU0
[22:27:03]I (483) main_task: Calling app_main()
[22:27:03][I][logger:171]: Log initialized
[22:27:03][D][zigbee:340]: Model: esp-h2-power-monitoring-1
[22:27:03][D][zigbee:341]: Manufacturer: esphome
[22:27:03][D][zigbee:342]: Date: 20250126
[22:27:03][D][zigbee:343]: Area: 
[22:27:03][D][esp-idf:000]: E (642) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x300 is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (644) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x400 is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (653) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x401 is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (664) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x508 is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (674) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x602 is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (684) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x603 is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (694) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x505 is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (705) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x600 is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (715) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x601 is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (725) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x50b is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (746) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x604 is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (756) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x605 is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (766) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x301 is not found
[22:27:03]
[22:27:03][E][zigbee:134]: Could not add attribute 0x0301 to cluster 0x0702 in endpoint 1: ESP_FAIL
[22:27:03][D][esp-idf:000]: E (786) ESP_ZIGBEE_ATTRIBUTE: The requested update attribute ID:0x302 is not found
[22:27:03]
[22:27:03][E][zigbee:134]: Could not add attribute 0x0302 to cluster 0x0702 in endpoint 1: ESP_FAIL
[22:27:03][I][app:029]: Running through setup()...
[22:27:03][C][uart.idf:093]: Setting up UART 1...
[22:27:03][D][esp-idf:000]: I (818) uart: queue free spaces: 20
[22:27:03]
[22:27:03][D][esp-idf:000]: I (832) phy: phy_version: 310,2, 463a420, Aug 15 2024, 18:52:11
[22:27:03]
[22:27:03][D][esp-idf:000]: I (833) phy: libbtbb version: a024da6, Aug 15 2024, 18:52:23
[22:27:03]
[22:27:03][D][esp-idf:000]: E (834) ESP_ZIGBEE_CLUSTER: The requested update cluster ID (0x   0) is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (838) zigbee_helper: Ignore previous cluster not found error
[22:27:03]
[22:27:03][D][esp-idf:000]: E (848) ESP_ZIGBEE_CLUSTER: The requested update cluster ID (0x 702) is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (858) zigbee_helper: Ignore previous cluster not found error
[22:27:03]
[22:27:03][D][esp-idf:000]: E (868) ESP_ZIGBEE_CLUSTER: The requested update cluster ID (0x b04) is not found
[22:27:03]
[22:27:03][D][esp-idf:000]: E (879) zigbee_helper: Ignore previous cluster not found error
[22:27:03]
[22:27:03][D][zigbee:465]: set reporting for cluster: 2820
[22:27:03][D][zigbee:465]: set reporting for cluster: 2820
[22:27:03][D][zigbee:465]: set reporting for cluster: 2820
[22:27:03][D][zigbee:465]: set reporting for cluster: 2820
[22:27:03][D][zigbee:465]: set reporting for cluster: 1794
[22:27:03][E][zigbee:474]: Could not configure reporting for attribute 0x0000 in cluster 0x0702 in endpoint 1
[22:27:03][I][app:062]: setup() finished successfully!
[22:27:03][I][app:100]: ESPHome version 2024.12.2 compiled on Jan 26 2025, 22:26:43
[22:27:03][C][logger:185]: Logger:
[22:27:03][C][logger:186]:   Level: DEBUG
[22:27:03][C][logger:188]:   Log Baud Rate: 115200
[22:27:03][C][logger:189]:   Hardware UART: UART0
[22:27:03][C][uart.idf:159]: UART Bus 1:
[22:27:03][C][uart.idf:160]:   TX Pin: GPIO10
[22:27:03][C][uart.idf:161]:   RX Pin: GPIO11
[22:27:03][C][uart.idf:163]:   RX Buffer Size: 256
[22:27:03][C][uart.idf:165]:   Baud Rate: 9600 baud
[22:27:03][C][uart.idf:166]:   Data Bits: 8
[22:27:03][C][uart.idf:167]:   Parity: NONE
[22:27:03][C][uart.idf:168]:   Stop bits: 1
[22:27:03][C][modbus:165]: Modbus:
[22:27:03][C][modbus:167]:   Send Wait Time: 250 ms
[22:27:03][C][modbus:168]:   CRC Disabled: NO
[22:27:03][D][pzemac:049]: PZEM AC: V=236.3 V, I=0.000 A, P=0.0 W, E=3.0 Wh, F=50.0 Hz, PF=0.00
[22:27:03][D][sensor:093]: 'PZEM-004T V3 Voltage': Sending state 236.30000 V with 1 decimals of accuracy
[22:27:03][D][sensor:093]: 'PZEM-004T V3 Current': Sending state 0.00000 A with 3 decimals of accuracy
[22:27:03][D][sensor:093]: 'PZEM-004T V3 Power': Sending state 0.00000 W with 2 decimals of accuracy
[22:27:03][D][sensor:093]: 'PZEM-004T V3 Energy': Sending state 3.00000 Wh with 0 decimals of accuracy
[22:27:03][D][sensor:093]: 'PZEM-004T V3 Frequency': Sending state 50.00000 Hz with 1 decimals of accuracy
[22:27:03][D][sensor:093]: 'PZEM-004T V3 Power Factor': Sending state 0.00000  with 2 decimals of accuracy
[22:27:03][W][component:237]: Component modbus took a long time for an operation (53 ms).
[22:27:03][W][component:238]: Components should block for at most 30 ms.
[22:27:03][D][zigbee:018]: Attribute set!
[22:27:03][D][zigbee:018]: Attribute set!
[22:27:03][D][zigbee:018]: Attribute set!
[22:27:03][D][zigbee:018]: Attribute set!
[22:27:03][D][zigbee:018]: Attribute set!
[22:27:03][C][pzemac:067]: PZEMAC:
[22:27:03][C][pzemac:068]:   Address: 0x01
[22:27:03][C][pzemac:069]: Voltage 'PZEM-004T V3 Voltage'
[22:27:03][C][pzemac:069]:   Device Class: 'voltage'
[22:27:03][C][pzemac:069]:   State Class: 'measurement'
[22:27:03][C][pzemac:069]:   Unit of Measurement: 'V'
[22:27:03][C][pzemac:069]:   Accuracy Decimals: 1
[22:27:03][C][pzemac:070]: Current 'PZEM-004T V3 Current'
[22:27:03][C][pzemac:070]:   Device Class: 'current'
[22:27:03][C][pzemac:070]:   State Class: 'measurement'
[22:27:03][C][pzemac:070]:   Unit of Measurement: 'A'
[22:27:03][C][pzemac:070]:   Accuracy Decimals: 3
[22:27:03][C][pzemac:071]: Power 'PZEM-004T V3 Power'
[22:27:03][C][pzemac:071]:   Device Class: 'power'
[22:27:03][C][pzemac:071]:   State Class: 'measurement'
[22:27:03][C][pzemac:071]:   Unit of Measurement: 'W'
[22:27:03][C][pzemac:071]:   Accuracy Decimals: 2
[22:27:03][C][pzemac:072]: Energy 'PZEM-004T V3 Energy'
[22:27:03][C][pzemac:072]:   Device Class: 'energy'
[22:27:03][C][pzemac:072]:   State Class: 'total_increasing'
[22:27:03][C][pzemac:072]:   Unit of Measurement: 'Wh'
[22:27:03][C][pzemac:072]:   Accuracy Decimals: 0
[22:27:03][C][pzemac:073]: Frequency 'PZEM-004T V3 Frequency'
[22:27:03][C][pzemac:073]:   State Class: 'measurement'
[22:27:03][C][pzemac:073]:   Unit of Measurement: 'Hz'
[22:27:03][C][pzemac:073]:   Accuracy Decimals: 1
[22:27:03][C][pzemac:073]:   Icon: 'mdi:current-ac'
[22:27:03][C][pzemac:074]: Power Factor 'PZEM-004T V3 Power Factor'
[22:27:03][C][pzemac:074]:   Device Class: 'power_factor'
[22:27:03][C][pzemac:074]:   State Class: 'measurement'
[22:27:03][C][pzemac:074]:   Unit of Measurement: ''
[22:27:03][C][pzemac:074]:   Accuracy Decimals: 2
[22:27:03][C][zigbee:490]: ZigBee:
[22:27:03][C][zigbee:492]: Endpoint: 1, 65520
[22:27:05][I][zigbee:137][Zigbee_main]: Network steering was not successful (status: ESP_FAIL)
[22:27:09][I][zigbee:137][Zigbee_main]: Network steering was not successful (status: ESP_FAIL)
[22:27:12][D][pzemac:049]: PZEM AC: V=235.8 V, I=0.000 A, P=0.0 W, E=3.0 Wh, F=50.0 Hz, PF=0.00
[22:27:12][D][sensor:093]: 'PZEM-004T V3 Voltage': Sending state 235.80000 V with 1 decimals of accuracy
[22:27:12][D][sensor:093]: 'PZEM-004T V3 Current': Sending state 0.00000 A with 3 decimals of accuracy
[22:27:12][D][sensor:093]: 'PZEM-004T V3 Power': Sending state 0.00000 W with 2 decimals of accuracy
[22:27:12][D][sensor:093]: 'PZEM-004T V3 Energy': Sending state 3.00000 Wh with 0 decimals of accuracy
[22:27:12][D][sensor:093]: 'PZEM-004T V3 Frequency': Sending state 50.00000 Hz with 1 decimals of accuracy
[22:27:12][D][sensor:093]: 'PZEM-004T V3 Power Factor': Sending state 0.00000  with 2 decimals of accuracy
[22:27:12][D][zigbee:018]: Attribute set!
[22:27:12][D][zigbee:018]: Attribute set!
[22:27:12][D][zigbee:018]: Attribute set!
[22:27:12][D][zigbee:018]: Attribute set!
[22:27:12][D][zigbee:018]: Attribute set!

Esphome Zigbee config

zigbee:
  id: "zb"
  endpoints:
    - device_type: TEST # TODO better device type ?
      num: 1
      clusters:
        ###
        # AC mains live information
        ###
        - id: ELECTRICAL_MEASUREMENT
          attributes:
            # Basic information
            - attribute_id: 0x0000
              type: 32BITMAP
              value: 0b10010001 # Active measurement, Phase A measurement, Power quality measurement

            # Frequency
            - attribute_id: 0x0300 # ACFrequency
              type: U16
              report: true
              value: 0xFFFF # Default for non readable value
              device: pzem_frequency
            - attribute_id: 0x0400 # ACFrequencyMultiplier
              type: U16
              report: false
              value: 0x0001
            - attribute_id: 0x0401 # ACFrequencyDivisor
              type: U16
              report: false
              value: 0x0001

            # Current
            - attribute_id: 0x0508 # RMSCurrent
              type: S16
              report: true
              value: 0xFFFF # Default for non readable value
              device: pzem_current
            - attribute_id: 0x0602 # ACCurrentMultiplier
              type: U16
              report: false
              value: 0x0001
            - attribute_id: 0x0603 # ACCurrentDivisor
              type: U16
              report: false
              value: 0x0001

            # Voltage
            - attribute_id: 0x0505 # RMSVoltage
              type: U16
              report: true
              value: 0xFFFF # Default for non readable value
              device: pzem_voltage
            - attribute_id: 0x0600 # ACVoltageMultiplier
              type: U16
              report: false
              value: 0x0001
            - attribute_id: 0x0601 # ACVoltageDivisor
              type: U16
              report: false
              value: 0x0001

            # Power
            - attribute_id: 0x050B # ActivePower
              type: S16
              report: true
              value: 0
              device: pzem_power
            - attribute_id: 0x0604 # ACPowerMultiplier
              type: U16
              report: false
              value: 0x0001
            - attribute_id: 0x0605 # ACPowerDivisor
              type: U16
              report: false
              value: 0x0001

        ###
        # Historical consumption
        ###
        - id: METERING
          attributes:
            - attribute_id: 0x0000 # CurrentSummationDelivered
              type: U48
              report: true
              value: 0
              device: pzem_energy
            - attribute_id: 0x0200 # Status
              type: 8BITMAP
              report: false
              value: 0 # No error to report
            - attribute_id: 0x0300 # UnitofMeasure
              type: 8BIT_ENUM
              report: false
              value: 0x00 # kWh (Kilowatt Hours) & kW (Kilowatts) in pure binary format
            - attribute_id: 0x0301 # Multiplier
              type: U24
              report: false
              value: 1
            - attribute_id: 0x0302 # Divisor
              type: U24
              report: false
              value: 1
            - attribute_id: 0x0303 # SummationFormatting
              type: 8BITMAP
              report: false
              value: 0b11111111
            - attribute_id: 0x0306 # MeteringDeviceType
              type: 8BITMAP
              report: false
              value: 0 # Electric Metering

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions