11#include "esp_zigbee_core.h"
13#include "ha/esp_zigbee_ha_standard.h"
19#ifdef USE_BINARY_SENSOR
26static const uint16_t ED_KEEP_ALIVE = 3000;
27static const uint8_t MAX_CHILDREN = 10;
29#define ESP_ZB_DEFAULT_RADIO_CONFIG() \
30 { .radio_mode = ZB_RADIO_MODE_NATIVE, }
32#define ESP_ZB_DEFAULT_HOST_CONFIG() \
33 { .host_connection_mode = ZB_HOST_CONNECTION_MODE_NONE, }
35uint8_t *
get_zcl_string(
const char *str, uint8_t max_size,
bool use_max_size =
false);
39class ZigbeeComponent :
public Component {
41 void setup()
override;
44 esp_err_t
create_endpoint(uint8_t endpoint_id, zb_ha_standard_devs_e device_id,
45 esp_zb_cluster_list_t *esp_zb_cluster_list);
47 void add_cluster(uint8_t endpoint_id, uint16_t cluster_id, uint8_t role);
51 void add_attr(ZigbeeAttribute *attr, uint8_t endpoint_id, uint16_t cluster_id, uint8_t role, uint16_t attr_id,
52 uint8_t max_size, T value);
55 void add_attr(uint8_t endpoint_id, uint16_t cluster_id, uint8_t role, uint16_t attr_id, uint8_t max_size, T value);
58 esp_zb_lock_acquire(portMAX_DELAY);
59 esp_zb_factory_reset();
60 esp_zb_lock_release();
83 esp_zb_nwk_device_type_t
device_role_ = ESP_ZB_DEVICE_TYPE_ROUTER;
91 std::map<uint8_t, std::tuple<zb_ha_standard_devs_e, esp_zb_cluster_list_t *>>
endpoint_list_;
93 std::map<std::tuple<uint8_t, uint16_t, uint8_t>, esp_zb_attribute_list_t *>
attribute_list_;
106 uint8_t max_size, T value) {
107 this->
add_attr<T>(
nullptr, endpoint_id, cluster_id, role, attr_id, max_size, value);
112 uint16_t attr_id, uint8_t max_size, T value) {
115 if constexpr (std::is_same<T, std::string>::value) {
117 add_attr_(attr, endpoint_id, cluster_id, role, attr_id, zcl_str);
119 }
else if constexpr (std::is_convertible<T, const char *>::value) {
121 add_attr_(attr, endpoint_id, cluster_id, role, attr_id, zcl_str);
124 add_attr_(attr, endpoint_id, cluster_id, role, attr_id, &value);
130 uint16_t attr_id, T *value_p) {
131 esp_zb_attribute_list_t *attr_list = this->
attribute_list_[{endpoint_id, cluster_id, role}];
134 if (attr !=
nullptr) {
135 this->
attributes_[{endpoint_id, cluster_id, role, attr_id}] = attr;
CallbackManager< void(bool)> join_cb_
esp_zb_ep_list_t * esp_zb_ep_list_
bool is_battery_powered()
std::map< std::tuple< uint8_t, uint16_t, uint8_t, uint16_t >, ZigbeeAttribute * > attributes_
esp_zb_nwk_device_type_t device_role_
void create_default_cluster(uint8_t endpoint_id, zb_ha_standard_devs_e device_id)
void add_cluster(uint8_t endpoint_id, uint16_t cluster_id, uint8_t role)
std::atomic< bool > joined
std::atomic< bool > factory_new
std::map< uint8_t, std::tuple< zb_ha_standard_devs_e, esp_zb_cluster_list_t * > > endpoint_list_
std::map< std::tuple< uint8_t, uint16_t, uint8_t >, esp_zb_attribute_list_t * > attribute_list_
void add_on_join_callback(F &&cb)
void dump_config() override
void set_basic_cluster(const char *model, const char *manufacturer, uint8_t power_source)
esp_err_t create_endpoint(uint8_t endpoint_id, zb_ha_standard_devs_e device_id, esp_zb_cluster_list_t *esp_zb_cluster_list)
struct esphome::zigbee::ZigbeeComponent::@199 basic_cluster_data_
std::atomic< bool > started
void add_attr(ZigbeeAttribute *attr, uint8_t endpoint_id, uint16_t cluster_id, uint8_t role, uint16_t attr_id, uint8_t max_size, T value)
esp_zb_attribute_list_t * create_basic_cluster_()
void add_attr_(ZigbeeAttribute *attr, uint8_t endpoint_id, uint16_t cluster_id, uint8_t role, uint16_t attr_id, T *value_p)
uint8_t * get_zcl_string(const char *str, uint8_t max_size, bool use_max_size)
void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
esp_err_t esphome_zb_cluster_add_or_update_attr(uint16_t cluster_id, esp_zb_attribute_list_t *attr_list, uint16_t attr_id, void *value_p)