ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
zigbee_attribute_base_esp32.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
4#ifdef USE_ESP32
5#ifdef USE_ZIGBEE
6
7namespace esphome::zigbee {
8
9ESPHOME_LOG_TAG(TAG, "zigbee.attribute");
10
12 if (!this->zb_->is_started()) {
13 return;
14 }
15 if (esp_zigbee_lock_acquire(10 / portTICK_PERIOD_MS)) {
16 ezb_zcl_status_t state = ezb_zcl_set_attr_value(this->endpoint_id_, this->cluster_id_, this->role_, this->attr_id_,
17 EZB_ZCL_STD_MANUF_CODE, this->value_p_, false);
18 this->set_attr_requested_ = false;
19 if (this->force_report_) {
20 this->report_internal(true);
21 }
22 esp_zigbee_lock_release();
23 // Check for error
24 if (state != EZB_ZCL_STATUS_SUCCESS) {
25 ESP_LOGE(TAG, "Setting attribute 0x%04X on cluster 0x%04X failed, ZCL status: %u", this->attr_id_,
26 this->cluster_id_, static_cast<unsigned>(state));
27 }
28 }
29}
30
32 if (!this->report_enabled) {
33 return;
34 }
35 if (!this->zb_->is_joined()) {
36 this->report_requested_ = true;
37 return;
38 }
39 if (has_lock or esp_zigbee_lock_acquire(10 / portTICK_PERIOD_MS)) {
40 ezb_zcl_report_attr_cmd_t cmd = {};
41 cmd.cmd_ctrl.fc.direction = EZB_ZCL_CMD_DIRECTION_TO_CLI;
42 cmd.cmd_ctrl.fc.dis_default_rsp = 1;
43 cmd.cmd_ctrl.dst_addr.addr_mode = EZB_ADDR_MODE_SHORT;
44 cmd.cmd_ctrl.dst_addr.u.short_addr = 0x0000;
45 cmd.cmd_ctrl.dst_ep = 1;
46 cmd.cmd_ctrl.src_ep = this->endpoint_id_;
47 cmd.cmd_ctrl.cluster_id = this->cluster_id_;
48 cmd.cmd_ctrl.fc.manuf_specific = 0;
49 cmd.payload.attr_id = this->attr_id_;
50
51 ezb_zcl_report_attr_cmd_req(&cmd);
52 this->report_requested_ = false;
53 if (!has_lock) {
54 esp_zigbee_lock_release();
55 }
56 }
57}
58
59} // namespace esphome::zigbee
60
61#endif
62#endif
bool state
Definition fan.h:2
ESPHOME_LOG_TAG(TAG, "zigbee.time")