espressif / esp-zigbee-sdk

Espressif Zigbee SDK
Apache License 2.0
178 stars 31 forks source link

esp_zigbee_type.h seems to be missing Zigbee HA standard illuminance sensor clusters. (TZ-1050) #401

Closed elgerg closed 3 months ago

elgerg commented 3 months ago

Answers checklist.

IDF version.

n/a

esp-zigbee-lib version.

Current

esp-zboss-lib version.

Unknown, looking at the source in this repo

Espressif SoC revision.

ESP32-H2

What is the expected behavior?

I'd expect a illuminance section in esp_zigbee_type.h similar to:

/**
 * @brief Zigbee HA standard temperature sensor clusters.
 *
 */
typedef struct esp_zb_temperature_sensor_cfg_s {
    esp_zb_basic_cluster_cfg_t basic_cfg;                /*!<  Basic cluster configuration, @ref esp_zb_basic_cluster_cfg_s */
    esp_zb_identify_cluster_cfg_t identify_cfg;          /*!<  Identify cluster configuration, @ref esp_zb_identify_cluster_cfg_s */
    esp_zb_temperature_meas_cluster_cfg_t temp_meas_cfg; /*!<  Temperature measurement cluster configuration, @ref esp_zb_temperature_meas_cluster_cfg_s */
} esp_zb_temperature_sensor_cfg_t;

What is the actual behavior?

Nothing, it's not there

Steps to reproduce.

open esp_zigbee_type.h and search for illuminance, there is only one section for attributes but not one for the cluster.

More Information.

No response

xieqinan commented 3 months ago

Hello @elgerg,

I couldn't find the definition for an illuminance sensor in the Zigbee Home Automation specification. Did you mean a light sensor? If so, adding the structure is straightforward. You can follow the code below.

#define ESP_ZB_DEFAULT_LIGHT_SENSOR_CONFIG()                                                            \
    {                                                                                                   \
        .basic_cfg =                                                                                    \
            {                                                                                           \
                .zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE,                              \
                .power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE,                            \
            },                                                                                          \
        .identify_cfg =                                                                                 \
            {                                                                                           \
                .identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE,                       \
            },                                                                                          \
        .illuminance_meas_cfg =                                                                         \
            {                                                                                           \
                .measured_value = ESP_ZB_ZCL_ILLUMINANCE_MEASUREMENT_LIGHT_SENSOR_TYPE_DEFAULT_VALUE,   \
                .min_value = ESP_ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MIN_MEASURED_VALUE_MIN_VALUE,      \
                .max_value = ESP_ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MAX_MEASURED_VALUE_MAX_VALUE,      \
            },                                                                                          \
    }

typedef struct esp_zb_light_sensor_cfg_s {
    esp_zb_basic_cluster_cfg_t basic_cfg;                /*!<  Basic cluster configuration, @ref esp_zb_basic_cluster_cfg_s */
    esp_zb_identify_cluster_cfg_t identify_cfg;          /*!<  Identify cluster configuration, @ref esp_zb_identify_cluster_cfg_s */
    esp_zb_illuminance_meas_cluster_cfg_t illuminance_meas_cfg;
} esp_zb_light_sensor_cfg_t;

We also will consider adding it in next version.

elgerg commented 3 months ago

Ah, my bad. I assume light sensor was illuminance based on this being in the header:

/**
 * @brief Zigbee standard mandatory attribute for illuminance measurement cluster
 *
 */
typedef struct esp_zb_illuminance_meas_cluster_cfg_s {
    uint16_t measured_value;                     /*!<  The attribute indicates the illuminance from 0x0000 to 0xffff */
    uint16_t min_value;                          /*!<  The attribute indicates minimum value of the measured value */
    uint16_t max_value;                          /*!<  The attribute indicates maximum value of the measured value */
} esp_zb_illuminance_meas_cluster_cfg_t;

So, to add your code do I need to edit my local version of esp_zigbee_type.h?

Sorry for the dumb questions, I'm trying to get this working under Arduino until the official wrapper is available.

Thanks in advance!

xieqinan commented 3 months ago

@elgerg ,

So, to add your code do I need to edit my local version of esp_zigbee_type.h?

I suggest adding the code to your local file. I'm concerned that adding it to esp_zigbee_type.h in the IDF component might cause a compilation issue.

P-R-O-C-H-Y commented 3 months ago

Hi @xieqinan, the light sensor is defined in Zigbee Home Automation specification as 0x0106. Can this be added please?

Snímek obrazovky 2024-08-14 v 16 25 45

Found that on multiple places.

xieqinan commented 3 months ago

@P-R-O-C-H-Y ,

the light sensor is defined in Zigbee Home Automation specification as 0x0106. Can this be added please?

The Light Sensor Number will also be added in the next release. In the meantime, please add it to your local file.

xieqinan commented 3 months ago

@elgerg ,

This issue has been resolved in esp-zigbee-sdk v1.5.0. Please update to this version and test again.