Closed kylemwagner83 closed 5 months ago
@kylemwagner83,
I believe that the temperature, humidity, and pressure attributes are similar. The issue may arise from different configurations for attribute reporting. Could you please show me how to configure report to the Zigbee device in the coordinator side? A Wireshark packet or code will be fine.
For the coordinator, I'm using a Sonoff USB Dongle: Sonoff ZigBee 3.0 USB Dongle Plus
I'm reading the Zigbee cluster values in Zigbee2MQTT using a custom converter:
The converter code is very straightforward:
const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const extend = require('zigbee-herdsman-converters/lib/extend');
const e = exposes.presets;
const ea = exposes.access;
const definition = {
zigbeeModel: ['ESP32C6.Sensor'],
model: 'ESP32C6',
vendor: 'Espressif',
description: 'ESP32C6 Sensor',
fromZigbee: [fz.humidity, fz.temperature, fz.pressure],
toZigbee: [], // Should be empty, unless device can be controlled (e.g. lights, switches).
exposes: [e.battery(), e.temperature(), e.humidity(), e.pressure()], // Defines what this device exposes, used for e.g. Home Assistant discovery and in the frontend
};
module.exports = definition;
Once the ESP32C6 joins my Zigbee network, In Zigbee2MQTT I can see the clusters I've defined:
But in the logs, when the esp_zb_zcl_report_attr_cmd_req functions are called, I see the temperature but not humidity or pressure, they both show as NULL:
Same in the state.json:
However, when the device first joins I can see the default value I've set by manually reading the attribute:
And after the esp_zb_zcl_set_attribute_val functions are called, I can also manually read the updated value:
So it looks like the attributes are getting set properly, but are not reporting properly.
@kylemwagner83,
Thank you for the detailed information. I believe that Zigbee2MQTT has already configured the attribute reporting. However, I am not sure whether the report information on the ESP32H2 side is correct. Could you please utilize the esp_zb_zcl_find_reporting_info()
function to locate the attribute report information? This function can help us determine whether the humidity and pressure clusters can correctly send the attribute reports.
Thank you for the advice, esp_zb_zcl_find_reporting_info()
was not available in esp-zigbee-lib 0.9.0, so in idf_component.yml I updated both esp-zigbee-lib and esp-zboss-lib to 1.1.1
This seems to have fixed the humidity and pressure reporting, so now all 3 attributes (temp, humidity, pressure) are updating in MQTT - if I set reporting intervals in Zigbee2MQTT.
I believe I'm still missing some reporting configuration to set report intervals in ESP-IDF code rather than in Zigbee2MQTT. I'm guessing this uses something like esp_zb_zcl_update_reporting_info()
. Is this correct and are there any code examples for setting report intervals?
Seems like there is still an issue with reporting, without manually setting report intervals in Zigbee2MQTT nothing is reported, esp_zb_zcl_report_attr_cmd_req()
doesn't send anything when called. I'm not sure what information would be most useful from the esp_zb_zcl_find_reporting_info()
command, I just printed what I can to console:
esp_zb_zcl_attr_location_info_t humidity_attr_info = {
HA_ESP_SENSOR_ENDPOINT,
ESP_ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT,
ESP_ZB_ZCL_CLUSTER_SERVER_ROLE,
ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC, //
ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID,
};
esp_zb_zcl_reporting_info_t humidity_reporting_state = *esp_zb_zcl_find_reporting_info(humidity_attr_info);
printf("Humidity report - direction: %i\n", humidity_reporting_state.direction);
printf("Humidity report - endpoint: %i\n", humidity_reporting_state.ep);
printf("Humidity report - cluster id: %i\n", humidity_reporting_state.cluster_id);
printf("Humidity report - cluster role: %i\n", humidity_reporting_state.cluster_role);
printf("Humidity report - attribute id: %i\n", humidity_reporting_state.attr_id);
printf("Humidity report - flags: %i\n", humidity_reporting_state.flags);
printf("Humidity report - run time: %lu\n", (unsigned long)humidity_reporting_state.run_time);
printf("Humidity report - actual min interval: %i\n", humidity_reporting_state.u.send_info.min_interval);
printf("Humidity report - actual max interval: %i\n", humidity_reporting_state.u.send_info.max_interval);
printf("Humidity report - default min interval: %i\n", humidity_reporting_state.u.send_info.def_min_interval);
printf("Humidity report - default max interval: %i\n", humidity_reporting_state.u.send_info.def_max_interval);
printf("Humidity report - timeout: %i\n", humidity_reporting_state.u.recv_info.timeout);
printf("Humidity report - dst short address: %i\n", humidity_reporting_state.dst.short_addr);
printf("Humidity report - dst endpoint: %i\n", humidity_reporting_state.dst.endpoint);
printf("Humidity report - dst profile id: %i\n", humidity_reporting_state.dst.profile_id);
printf("Humidity report - manufacturer code: %i\n", humidity_reporting_state.manuf_code);
Here is the output:
Humidity report - direction: 0
Humidity report - endpoint: 1
Humidity report - cluster id: 1029
Humidity report - cluster role: 1
Humidity report - attribute id: 0
Humidity report - flags: 33
Humidity report - run time: 425
Humidity report - actual min interval: 5
Humidity report - actual max interval: 0
Humidity report - default min interval: 5
Humidity report - default max interval: 0
Humidity report - timeout: 5
Humidity report - dst short address: 0
Humidity report - dst endpoint: 0
Humidity report - dst profile id: 260
Humidity report - manufacturer code: 65535
When I try to configure the report using esp_zb_zcl_config_report_cmd_req()
, it crashes (specifically when setting anything in the record_field), here is the code and output:
esp_zb_zcl_config_report_record_t report_record;
report_record.attributeID = ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID;
report_record.attrType = ESP_ZB_ZCL_ATTR_TYPE_U32;
report_record.min_interval = 1;
report_record.max_interval = 4;
report_record.reportable_change = 0;
esp_zb_zcl_config_report_cmd_t report_cmd;
report_cmd.zcl_basic_cmd.dst_addr_u.addr_short=esp_zb_get_short_address();
report_cmd.zcl_basic_cmd.dst_endpoint = 1;
report_cmd.zcl_basic_cmd.src_endpoint = 1;
report_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_16_ENDP_PRESENT;
report_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT;
report_cmd.record_field = &report_record;
esp_zb_zcl_config_report_cmd_req(&report_cmd);
I (1489) phy_init: phy_version 230,c773401,Oct 30 2023,15:07:16
I (1519) phy: libbtbb version: 7243671, Oct 30 2023, 15:07:30
I (1549) ESP32C6_BME280: ZDO signal: ZDO Config Ready (0x17), status: ESP_FAIL
I (1549) ESP32C6_BME280: Zigbee stack initialized
I (4039) ESP32C6_BME280: Start network steering
I (4049) ESP32C6_BME280: Joined network successfully (Extended PAN ID: a6:c0:b0:17:73:67:44:94, PAN ID: 0x45fa, Channel:11)
Guru Meditation Error: Core 0 panic'ed (Load access fault). Exception was unhandled.
Core 0 register dump:
MEPC : 0x4203104a RA : 0x42010e64 SP : 0x4081d040 GP : 0x40810004
0x4203104a: zb_zcl_put_value_to_packet at ??:?
0x42010e64: esp_zb_zcl_config_report_cmd_req at ??:?
TP : 0x4080ca9c T0 : 0x40030dca T1 : 0x000000ff T2 : 0xffffffff
0x4080ca9c: mmu_hal_pages_to_bytes at C:/Users/kylem/esp/esp-idf/components/hal/mmu_hal.c:43
0x40030dca: memset in ROM
S0/FP : 0x40813717 S1 : 0x40813717 A0 : 0x40813717 A1 : 0x00000000
A2 : 0x00000000 A3 : 0x00000023 A4 : 0x00000023 A5 : 0x00000023
A6 : 0x00000018 A7 : 0x00000001 S2 : 0x00000000 S3 : 0x00000019
S4 : 0x00000000 S5 : 0x00000000 S6 : 0x00000000 S7 : 0x00000000
S8 : 0x00000000 S9 : 0x00000000 S10 : 0x00000000 S11 : 0x00000000
T3 : 0x00000000 T4 : 0x00024201 T5 : 0xffffffff T6 : 0xffffffff
MSTATUS : 0x00001881 MTVEC : 0x40800001 MCAUSE : 0x00000005 MTVAL : 0x00000000
0x40800001: _vector_table at ??:?
MHARTID : 0x00000000
Stack memory:
4081d040: 0x4080fb58 0x4087f0f0 0x4081d0f8 0x00000019 0x00000000 0x40813717 0x4081d0f8 0x42010e64
0x42010e64: esp_zb_zcl_config_report_cmd_req at ??:?
4081d060: 0x4080fb58 0x4087f0f0 0x00000001 0x42010ce6 0x00000000 0x00000000 0x00000000 0x00000000
0x42010ce6: esp_zb_zcl_report_attr_cmd_req at ??:?
4081d080: 0x00000000 0x00000001 0x00000000 0x42008a12 0x4080c30a 0x4080c302 0x4081d110 0x40810004
0x42008a12: zb_update_humidity at D:/Coding/esp32c6-bme280-zigbee/main/zigbee/zb_update_attr.c:103
0x4080c30a: vPortYield at C:/Users/kylem/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:404 (discriminator 3)
0x4080c302: vPortYield at C:/Users/kylem/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:404 (discriminator 3)
4081d0a0: 0x4080ca9c 0x40030dca 0x000000ff 0x00000d31 0x0000012c 0x00000000 0x00000001 0x00000001
0x4080ca9c: mmu_hal_pages_to_bytes at C:/Users/kylem/esp/esp-idf/components/hal/mmu_hal.c:43
0x40030dca: memset in ROM
4081d0c0: 0x0000019e 0x00000004 0x00000001 0x00000001 0x420596b8 0x4087f05c 0x00000000 0x00000000
0x420596b8: event_write at C:/Users/kylem/esp/esp-idf/components/vfs/vfs_eventfd.c:243
4081d0e0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x0000bbb9 0x00000000
4081d100: 0x00000101 0x00000002 0xffff0405 0x4081d110 0x00000000 0x00230000 0x00040001 0x00000000
4081d120: 0x4206c2cc 0x00000000 0x50001000 0x42008d2a 0x4206c298 0x00000000 0x50001000 0x420096c6
0x50001000: esp_wake_stub_entry at C:/Users/kylem/esp/esp-idf/components/esp_hw_support/sleep_modes.c:286
0x42008d2a: update_attributes at D:/Coding/esp32c6-bme280-zigbee/main/main.c:50 (discriminator 2)
0x50001000: esp_wake_stub_entry at C:/Users/kylem/esp/esp-idf/components/esp_hw_support/sleep_modes.c:286
0x420096c6: esp_zb_zcl_attr_list_create at ??:?
4081d140: 0x4206ad10 0x0000018f 0x4206b000 0x42062a0c 0x00000000 0x00001388 0x00000000 0x00000000
0x42062a0c: main_task at C:/Users/kylem/esp/esp-idf/components/freertos/app_startup.c:209 (discriminator 13)
4081d160: 0x00000000 0x00000000 0x00000000 0x4080c152 0x00000000 0x00000000 0x00000000 0x00000000
0x4080c152: vPortTaskWrapper at C:/Users/kylem/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:205
4081d180: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
4081d1a0: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0x00000154 0x4081d090 0x0000019e 0x40811450 0x40811450
4081d1c0: 0x4081d1b0 0x40811448 0x00000018 0x4087dff4 0x4087dff4 0x4081d1b0 0x00000000 0x00000001
4081d1e0: 0x4081c1ac 0x6e69616d 0x23102100 0xeb38777f 0x0084d1fe 0x00000000 0x4081d1a0 0x00000001
4081d200: 0x00000000 0x00000000 0x00000000 0x00000000 0x4081aa88 0x4081aaf0 0x4081ab58 0x00000000
4081d220: 0x00000000 0x00000001 0x00000000 0x00000000 0x4087e078 0x42060ba6 0x00000000 0x00000000
0x42060ba6: _cleanup_r at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/riscv32-esp-elf/src/newlib/newlib/libc/stdio/findfp.c:229
4081d240: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4081d260: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4081d280: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4081d2a0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4081d2c0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4081d2e0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4081d300: 0x40000000 0x00000600 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
0x40000000: _start in ROM
4081d320: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
4081d340: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
4081d360: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
4081d380: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
4081d3a0: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
4081d3c0: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
4081d3e0: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
4081d400: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
4081d420: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
ELF file SHA256: 9da32ebc678fbdb3
Rebooting...
ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0xc (SW_CPU),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x4001975a
0x4001975a: software_reset_cpu in ROM
@kylemwagner83 ,
Please use the esp_zb_zcl_update_reporting_info()
function to update the report information, then use the esp_zb_zcl_find_reporting_info()
function to verify whether it has been updated.
The attribute type of ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID
should be ESP_ZB_ZCL_ATTR_TYPE_U16
. Could you update it and try again?
I ended up restructuring my program using the HA_Temperature_Sensor/HA_Thermostat examples and the reporting seems to be working now. At least part of the problem seems to have been calling esp_zb_zcl_update_reporting_info() after the main loop iteration. Handling the reporting configuration as part of the cluster/attribute setup in esp_zb_task prior to starting the main loop works. Thanks!
Answers checklist.
IDF version.
v5.1.2
esp-zigbee-lib version.
0.9.0
esp-zboss-lib version.
0.7.0
Espressif SoC revision.
ESP32-C6
What is the expected behavior?
Update and report ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID and ESP_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_VALUE_ID
What is the actual behavior?
Reporting works fine for temperature, but not for humidity or pressure. Nothing happens when esp_zb_zcl_report_attr_cmd_t is called for humidity/pressure, no errors are thrown, and the values are not reported.
Steps to reproduce.
Here is the esp_zb_task function, defining the clusters, attributes/default values, cluster/endpoint lists:
Here are the functions to update and report the 3 attributes:
More Information.
The zb_update_temperature function works as expected, the ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID is updated, and the new value is properly reported to the coordinator.
The zb_update_humidity and zb_update_pressure don't work, it appears the attributes are updated in their respective clusters (I can see the updated values if I manually read the cluster), but are not automatically reported.