Open matteovisotto opened 4 months ago
@matteovisotto ,
Attribute definition is correct?
The attribute definition appears correct from the overview. However, I recommend using the code below to create the basic cluster, which includes all the mandatory attributes of the basic cluster.
esp_zb_attribute_list_t *esp_zb_basic_cluster = esp_zb_basic_cluster_create(NULL);
esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, &manufname[0]);
esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, &modelid[0]);
The switch configuration is able to get commands from the coordinator, but it also report its state?
The esp-zigbee-sdk does not currently support the discovery command
, but it will be supported in the future.
How can I make the application to report a change in the water value ?
You can refer to the temperature sensor example in the esp-zigbee-sdk to implement the reporting feature.
I would like to add an additional attribute to the custom cluster to add a calibration parameter (that I have to save). How can I do this?
I think it has already been done correctly in your code.
By the way, which ESP Zigbee libraries are you using in your project? I believe they might be outdated, and I advise updating to the latest version.
Thanks @xieqinan. I'm using sdk v.1.0.9
For the configuration parameter I mean: let's take the minWaterpercent and maxWaterPercent (the name should be changed since are not a percentage). Both should be configured from zigbee2mqtt to set the sensor value corresponding to the empty and full state. So I need to read the actual configuration but also to write and persist in NVRAM a new configuration.
I suppose I have to set the attribute type as ESP_ZB_ZCL_ATTR_ACCESS_READ_WRITE (correct?)
Then the second problem arises in zb_attribute_handler
where I do not know how to target the correct attribute in message->attribute.id == ????
since it is a custom cluster.
While I was writing the converter for Zigbee2MQTT a new question arise.
Setting an attribute as ACCESS_READ_WRITE in a SERVER_ROLE cluster, require a command action or a write action from the coordinator send the value correctly ?
@matteovisotto ,
So I need to read the actual configuration but also to write and persist in NVRAM a new configuration. I suppose I have to set the attribute type as ESP_ZB_ZCL_ATTR_ACCESS_READ_WRITE (correct?)
The latest v1.4.1 version still does not support recording the attribute to NVRAM. This operation needs to be completed at the application layer for now.
Then the second problem arises in zb_attribute_handler where I do not know how to target the correct attribute in message-attribute.id == ???? since it is a custom cluster.
The custom cluster ID and attribute ID are defined by you, so why are you unsure how to set them?
Setting an attribute as ACCESS_READ_WRITE in a SERVER_ROLE cluster, require a command action or a write action from the coordinator send the value correctly ?
I think you need to provide a more detailed description of this issue, as I can only understand part of your message. Do you mean that you expect to write an attribute with ACCESS_READ_WRITE
access in the SERVER_ROLE
cluster? Should the writing operation be done in the CLIENT_ROLE
(coordinator)? The answer is yes.
@xieqinan I solved the first two problems and they work. For the third one, I'm sorry, it's confusing. I mean: As a coordinator I use the Zigbee2MQTT software that plays the role of client. The device I'm developing is a ROUTER (so similar to an end device), I have the custom cluster defined as follow (something changed from the first message):
esp_zb_attribute_list_t *esp_zb_water_level_cluster = esp_zb_zcl_attr_list_create(0xfc01);
esp_zb_cluster_add_attr(esp_zb_water_level_cluster, 0xfc01, 0x0000, ESP_ZB_ZCL_ATTR_TYPE_U16, ESP_ZB_ZCL_ATTR_ACCESS_REPORTING, &water_values->value);
esp_zb_cluster_add_attr(esp_zb_water_level_cluster, 0xfc01, 0x0001, ESP_ZB_ZCL_ATTR_TYPE_U16, ESP_ZB_ZCL_ATTR_ACCESS_READ_WRITE, &water_values->tankHeight);
esp_zb_cluster_add_attr(esp_zb_water_level_cluster, 0xfc01, 0x0002, ESP_ZB_ZCL_ATTR_TYPE_U16, ESP_ZB_ZCL_ATTR_ACCESS_READ_WRITE, &water_values->elevation);
the first attribute is a REPORTING one and it works.
The other two attribute which I set to ESP_ZB_ZCL_ATTR_ACCESS_READ_WRITE
must accept bot set and get operation from the coordinator.
While the set command is correctly executed, the device receive the new value as a ESP_ZB_CORE_SET_ATTR_VALUE_CB_ID
, the get operation (a read) doesn't work. When the coordinator try to request the value nothing happens.
To give more information, even if out of scope here, on the coordinator side the attribute definition is Zigbee2MQTT is:
tankHeight: {
key: ['tankHeight'],
convertSet: async (entity, key, value, meta) => {
var v = value * 100;
const payload = {tankHeight: v};
await entity.write('mvManuWaterLevel',payload); // THIS WORK
return {'tankHeight': v};
},
convertGet: async (entity, key, meta) => {
await entity.read('mvManuWaterLevel', ['tankHeight']); //THIS DOES NOT WORK
},
},
where mvManuWaterLevel
is the cluster id and tankHeight
is the attribute id.
@matteovisotto ,
The read attribute command will not trigger any application operation on the device. Has the read attribute response from device been received by the coordinator?
Question
Hi, I would like to define a more complex application compared to the examples. I need to configure three clusters:
I write some code that compile but I have some questions:
This is the code I have at the moment:
Thanks
Additional context.
No response