Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/en/zigbee/ep_carbon_dioxide_sensor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ Sets the minimum and maximum measurement values.

This function will return ``true`` if successful, ``false`` otherwise.

setDefaultValue
^^^^^^^^^^^^^^^

Sets the default (initial) value for the carbon dioxide sensor in ppm. This value will be used as the initial measured value when the device is in factory reset mode and before the sensor provides actual readings.

.. code-block:: arduino

bool setDefaultValue(float defaultValue);

* ``defaultValue`` - Default CO2 concentration value in ppm

**Important:** Must be called before adding the EP to Zigbee class. Only effective when the device is in factory reset mode (before commissioning/joining a network).

This function will return ``true`` if successful, ``false`` otherwise.

setTolerance
^^^^^^^^^^^^

Expand Down
15 changes: 15 additions & 0 deletions docs/en/zigbee/ep_flow_sensor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ Sets the minimum and maximum measurement values.

This function will return ``true`` if successful, ``false`` otherwise.

setDefaultValue
^^^^^^^^^^^^^^^

Sets the default (initial) value for the flow sensor in 0.1 m³/h. This value will be used as the initial measured value when the device is in factory reset mode and before the sensor provides actual readings.

.. code-block:: arduino

bool setDefaultValue(float defaultValue);

* ``defaultValue`` - Default flow rate value in 0.1 m³/h

**Important:** Must be called before adding the EP to Zigbee class. Only effective when the device is in factory reset mode (before commissioning/joining a network).

This function will return ``true`` if successful, ``false`` otherwise.

setTolerance
^^^^^^^^^^^^

Expand Down
15 changes: 15 additions & 0 deletions docs/en/zigbee/ep_illuminance_sensor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ Sets the minimum and maximum measurement values.

This function will return ``true`` if successful, ``false`` otherwise.

setDefaultValue
^^^^^^^^^^^^^^^

Sets the default (initial) value for the illuminance sensor. This value will be used as the initial measured value when the device is in factory reset mode and before the sensor provides actual readings.

.. code-block:: arduino
bool setDefaultValue(uint16_t defaultValue);
* ``defaultValue`` - Default illuminance value in lux

**Important:** Must be called before adding the EP to Zigbee class. Only effective when the device is in factory reset mode (before commissioning/joining a network).

This function will return ``true`` if successful, ``false`` otherwise.

setTolerance
^^^^^^^^^^^^

Expand Down
15 changes: 15 additions & 0 deletions docs/en/zigbee/ep_pm25_sensor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ Sets the minimum and maximum measurement values.

This function will return ``true`` if successful, ``false`` otherwise.

setDefaultValue
^^^^^^^^^^^^^^^

Sets the default (initial) value for the PM2.5 sensor in 0.1 μg/m³. This value will be used as the initial measured value when the device is in factory reset mode and before the sensor provides actual readings.

.. code-block:: arduino

bool setDefaultValue(float defaultValue);

* ``defaultValue`` - Default PM2.5 concentration value in 0.1 μg/m³

**Important:** Must be called before adding the EP to Zigbee class. Only effective when the device is in factory reset mode (before commissioning/joining a network).

This function will return ``true`` if successful, ``false`` otherwise.

setTolerance
^^^^^^^^^^^^

Expand Down
15 changes: 15 additions & 0 deletions docs/en/zigbee/ep_pressure_sensor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ Sets the minimum and maximum measurement values.

This function will return ``true`` if successful, ``false`` otherwise.

setDefaultValue
^^^^^^^^^^^^^^^

Sets the default (initial) value for the pressure sensor in 1 hPa. This value will be used as the initial measured value when the device is in factory reset mode and before the sensor provides actual readings.

.. code-block:: arduino

bool setDefaultValue(int16_t defaultValue);

* ``defaultValue`` - Default pressure value in hPa

**Important:** Must be called before adding the EP to Zigbee class. Only effective when the device is in factory reset mode (before commissioning/joining a network).

This function will return ``true`` if successful, ``false`` otherwise.

setTolerance
^^^^^^^^^^^^

Expand Down
15 changes: 15 additions & 0 deletions docs/en/zigbee/ep_temperature_sensor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ Sets the minimum and maximum temperature values for the sensor.

This function will return ``true`` if successful, ``false`` otherwise.

setDefaultValue
^^^^^^^^^^^^^^^

Sets the default (initial) value for the temperature sensor in 0.01°C resolution. This value will be used as the initial measured value when the device is in factory reset mode and before the sensor provides actual readings.

.. code-block:: arduino
bool setDefaultValue(float defaultValue);
* ``defaultValue`` - Default temperature value in degrees Celsius

**Important:** Must be called before adding the EP to Zigbee class. Only effective when the device is in factory reset mode (before commissioning/joining a network).

This function will return ``true`` if successful, ``false`` otherwise.

setTolerance
^^^^^^^^^^^^

Expand Down
15 changes: 15 additions & 0 deletions docs/en/zigbee/ep_wind_speed_sensor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ Sets the minimum and maximum measurement values.

This function will return ``true`` if successful, ``false`` otherwise.

setDefaultValue
^^^^^^^^^^^^^^^

Sets the default (initial) value for the wind speed sensor in 0.01 m/s. This value will be used as the initial measured value when the device is in factory reset mode and before the sensor provides actual readings.

.. code-block:: arduino

bool setDefaultValue(float defaultValue);

* ``defaultValue`` - Default wind speed value in 0.01 m/s

**Important:** Must be called before adding the EP to Zigbee class. Only effective when the device is in factory reset mode (before commissioning/joining a network).

This function will return ``true`` if successful, ``false`` otherwise.

setTolerance
^^^^^^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,18 @@ void setup() {
// Set minimum and maximum temperature measurement value (10-50°C is default range for chip temperature measurement)
zbTempSensor.setMinMaxValue(10, 50);

// Set default (initial) value for the temperature sensor to 10.0°C to match the minimum temperature measurement value (default value is 0.0°C)
zbTempSensor.setDefaultValue(10.0);

// Set tolerance for temperature measurement in °C (lowest possible value is 0.01°C)
zbTempSensor.setTolerance(1);

// Set power source to battery, battery percentage and battery voltage (now 100% and 3.5V for demonstration)
// The value can be also updated by calling zbTempSensor.setBatteryPercentage(percentage) or zbTempSensor.setBatteryVoltage(voltage) anytime after Zigbee.begin()
zbTempSensor.setPowerSource(ZB_POWER_SOURCE_BATTERY, 100, 35);

// Add humidity cluster to the temperature sensor device with min, max and tolerance values
zbTempSensor.addHumiditySensor(0, 100, 1);
// Add humidity cluster to the temperature sensor device with min, max, tolerance and default values
zbTempSensor.addHumiditySensor(0, 100, 1, 0.0);

// Set callback for default response to handle status of reported data, there are 2 options.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ void setup() {
// Set minimum and maximum temperature measurement value (10-50°C is default range for chip temperature measurement)
zbTempSensor.setMinMaxValue(10, 50);

// Optional: Set default (initial) value for the temperature sensor to 10.0°C to match the minimum temperature measurement value
zbTempSensor.setDefaultValue(10.0);

// Optional: Set tolerance for temperature measurement in °C (lowest possible value is 0.01°C)
zbTempSensor.setTolerance(1);

Expand Down
13 changes: 13 additions & 0 deletions libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ ZigbeeCarbonDioxideSensor::ZigbeeCarbonDioxideSensor(uint8_t endpoint) : ZigbeeE
_ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_SIMPLE_SENSOR_DEVICE_ID, .app_device_version = 0};
}

bool ZigbeeCarbonDioxideSensor::setDefaultValue(float defaultValue) {
float zb_default_value = defaultValue / 1000000.0f;
esp_zb_attribute_list_t *carbon_dioxide_measure_cluster =
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_CARBON_DIOXIDE_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
esp_err_t ret =
esp_zb_cluster_update_attr(carbon_dioxide_measure_cluster, ESP_ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MEASURED_VALUE_ID, (void *)&zb_default_value);
if (ret != ESP_OK) {
log_e("Failed to set default value: 0x%x: %s", ret, esp_err_to_name(ret));
return false;
}
return true;
}

bool ZigbeeCarbonDioxideSensor::setMinMaxValue(float min, float max) {
float zb_min = min / 1000000.0f;
float zb_max = max / 1000000.0f;
Expand Down
4 changes: 4 additions & 0 deletions libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class ZigbeeCarbonDioxideSensor : public ZigbeeEP {
// Set the carbon dioxide value in ppm
bool setCarbonDioxide(float carbon_dioxide);

// Set the default (initial) value for the carbon dioxide sensor in ppm
// Must be called before adding the EP to Zigbee class. Only effective in factory reset mode (before commissioning)
bool setDefaultValue(float defaultValue);

// Set the min and max value for the carbon dioxide sensor in ppm
bool setMinMaxValue(float min, float max);

Expand Down
12 changes: 12 additions & 0 deletions libraries/Zigbee/src/ep/ZigbeeFlowSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ ZigbeeFlowSensor::ZigbeeFlowSensor(uint8_t endpoint) : ZigbeeEP(endpoint) {
_ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_SIMPLE_SENSOR_DEVICE_ID, .app_device_version = 0};
}

bool ZigbeeFlowSensor::setDefaultValue(float defaultValue) {
uint16_t zb_default_value = (uint16_t)(defaultValue * 10);
esp_zb_attribute_list_t *flow_measure_cluster =
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_FLOW_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
esp_err_t ret = esp_zb_cluster_update_attr(flow_measure_cluster, ESP_ZB_ZCL_ATTR_FLOW_MEASUREMENT_VALUE_ID, (void *)&zb_default_value);
if (ret != ESP_OK) {
log_e("Failed to set default value: 0x%x: %s", ret, esp_err_to_name(ret));
return false;
}
return true;
}

bool ZigbeeFlowSensor::setMinMaxValue(float min, float max) {
uint16_t zb_min = (uint16_t)(min * 10);
uint16_t zb_max = (uint16_t)(max * 10);
Expand Down
4 changes: 4 additions & 0 deletions libraries/Zigbee/src/ep/ZigbeeFlowSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class ZigbeeFlowSensor : public ZigbeeEP {
// Set the flow value in 0,1 m3/h
bool setFlow(float value);

// Set the default (initial) value for the flow sensor in 0,1 m3/h
// Must be called before adding the EP to Zigbee class. Only effective in factory reset mode (before commissioning)
bool setDefaultValue(float defaultValue);

// Set the min and max value for the flow sensor in 0,1 m3/h
bool setMinMaxValue(float min, float max);

Expand Down
11 changes: 11 additions & 0 deletions libraries/Zigbee/src/ep/ZigbeeIlluminanceSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ ZigbeeIlluminanceSensor::ZigbeeIlluminanceSensor(uint8_t endpoint) : ZigbeeEP(en
_ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_LIGHT_SENSOR_DEVICE_ID, .app_device_version = 0};
}

bool ZigbeeIlluminanceSensor::setDefaultValue(uint16_t defaultValue) {
esp_zb_attribute_list_t *light_measure_cluster =
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_ILLUMINANCE_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
esp_err_t ret = esp_zb_cluster_update_attr(light_measure_cluster, ESP_ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MEASURED_VALUE_ID, (void *)&defaultValue);
if (ret != ESP_OK) {
log_e("Failed to set default value: 0x%x: %s", ret, esp_err_to_name(ret));
return false;
}
return true;
}

bool ZigbeeIlluminanceSensor::setMinMaxValue(uint16_t min, uint16_t max) {
esp_zb_attribute_list_t *light_measure_cluster =
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_ILLUMINANCE_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
Expand Down
4 changes: 4 additions & 0 deletions libraries/Zigbee/src/ep/ZigbeeIlluminanceSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class ZigbeeIlluminanceSensor : public ZigbeeEP {
// Set the illuminance value
bool setIlluminance(uint16_t value);

// Set the default (initial) value for the illuminance sensor
// Must be called before adding the EP to Zigbee class. Only effective in factory reset mode (before commissioning)
bool setDefaultValue(uint16_t defaultValue);

// Set the min and max value for the illuminance sensor
bool setMinMaxValue(uint16_t min, uint16_t max);

Expand Down
11 changes: 11 additions & 0 deletions libraries/Zigbee/src/ep/ZigbeePM25Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ ZigbeePM25Sensor::ZigbeePM25Sensor(uint8_t endpoint) : ZigbeeEP(endpoint) {
_ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_SIMPLE_SENSOR_DEVICE_ID, .app_device_version = 0};
}

bool ZigbeePM25Sensor::setDefaultValue(float defaultValue) {
esp_zb_attribute_list_t *pm2_5_measure_cluster =
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_PM2_5_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
esp_err_t ret = esp_zb_cluster_update_attr(pm2_5_measure_cluster, ESP_ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MEASURED_VALUE_ID, (void *)&defaultValue);
if (ret != ESP_OK) {
log_e("Failed to set default value: 0x%x: %s", ret, esp_err_to_name(ret));
return false;
}
return true;
}

bool ZigbeePM25Sensor::setMinMaxValue(float min, float max) {
esp_zb_attribute_list_t *pm2_5_measure_cluster =
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_PM2_5_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
Expand Down
4 changes: 4 additions & 0 deletions libraries/Zigbee/src/ep/ZigbeePM25Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class ZigbeePM25Sensor : public ZigbeeEP {
// Set the PM2.5 value in 0.1 µg/m³
bool setPM25(float pm25);

// Set the default (initial) value for the PM2.5 sensor in 0.1 µg/m³
// Must be called before adding the EP to Zigbee class. Only effective in factory reset mode (before commissioning)
bool setDefaultValue(float defaultValue);

// Set the min and max value for the PM2.5 sensor in 0.1 µg/m³
bool setMinMaxValue(float min, float max);

Expand Down
11 changes: 11 additions & 0 deletions libraries/Zigbee/src/ep/ZigbeePressureSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ ZigbeePressureSensor::ZigbeePressureSensor(uint8_t endpoint) : ZigbeeEP(endpoint
_ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_SIMPLE_SENSOR_DEVICE_ID, .app_device_version = 0};
}

bool ZigbeePressureSensor::setDefaultValue(int16_t defaultValue) {
esp_zb_attribute_list_t *pressure_measure_cluster =
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
esp_err_t ret = esp_zb_cluster_update_attr(pressure_measure_cluster, ESP_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_VALUE_ID, (void *)&defaultValue);
if (ret != ESP_OK) {
log_e("Failed to set default value: 0x%x: %s", ret, esp_err_to_name(ret));
return false;
}
return true;
}

bool ZigbeePressureSensor::setMinMaxValue(int16_t min, int16_t max) {
esp_zb_attribute_list_t *pressure_measure_cluster =
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
Expand Down
4 changes: 4 additions & 0 deletions libraries/Zigbee/src/ep/ZigbeePressureSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class ZigbeePressureSensor : public ZigbeeEP {
// Set the pressure value in 1 hPa
bool setPressure(int16_t value);

// Set the default (initial) value for the pressure sensor in 1 hPa
// Must be called before adding the EP to Zigbee class. Only effective in factory reset mode (before commissioning)
bool setDefaultValue(int16_t defaultValue);

// Set the min and max value for the pressure sensor in 1 hPa
bool setMinMaxValue(int16_t min, int16_t max);

Expand Down
19 changes: 17 additions & 2 deletions libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ ZigbeeTempSensor::ZigbeeTempSensor(uint8_t endpoint) : ZigbeeEP(endpoint) {
esp_zb_temperature_sensor_cfg_t temp_sensor_cfg = ESP_ZB_DEFAULT_TEMPERATURE_SENSOR_CONFIG();
_cluster_list = esp_zb_temperature_sensor_clusters_create(&temp_sensor_cfg);

// Set default (initial) value for the temperature sensor to 0.0°C
setDefaultValue(0.0);

_ep_config = {
.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_TEMPERATURE_SENSOR_DEVICE_ID, .app_device_version = 0
};
Expand Down Expand Up @@ -49,6 +52,18 @@ bool ZigbeeTempSensor::setMinMaxValue(float min, float max) {
return true;
}

bool ZigbeeTempSensor::setDefaultValue(float defaultValue) {
int16_t zb_default_value = zb_float_to_s16(defaultValue);
esp_zb_attribute_list_t *temp_measure_cluster =
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
esp_err_t ret = esp_zb_cluster_update_attr(temp_measure_cluster, ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID, (void *)&zb_default_value);
if (ret != ESP_OK) {
log_e("Failed to set default value: 0x%x: %s", ret, esp_err_to_name(ret));
return false;
}
return true;
}

bool ZigbeeTempSensor::setTolerance(float tolerance) {
// Convert tolerance to ZCL uint16_t
uint16_t zb_tolerance = (uint16_t)(tolerance * 100);
Expand Down Expand Up @@ -126,11 +141,11 @@ bool ZigbeeTempSensor::reportTemperature() {
return true;
}

void ZigbeeTempSensor::addHumiditySensor(float min, float max, float tolerance) {
void ZigbeeTempSensor::addHumiditySensor(float min, float max, float tolerance, float defaultValue) {
uint16_t zb_min = (uint16_t)(min * 100);
uint16_t zb_max = (uint16_t)(max * 100);
uint16_t zb_tolerance = (uint16_t)(tolerance * 100);
uint16_t default_hum = ESP_ZB_ZCL_REL_HUMIDITY_MEASUREMENT_MEASURED_VALUE_DEFAULT;
uint16_t default_hum = (uint16_t)(defaultValue * 100);
esp_zb_attribute_list_t *humidity_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT);
esp_zb_humidity_meas_cluster_add_attr(humidity_cluster, ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID, &default_hum);
esp_zb_humidity_meas_cluster_add_attr(humidity_cluster, ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_ID, &zb_min);
Expand Down
6 changes: 5 additions & 1 deletion libraries/Zigbee/src/ep/ZigbeeTempSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class ZigbeeTempSensor : public ZigbeeEP {
// Set the temperature value in 0,01°C
bool setTemperature(float value);

// Set the default (initial) value for the temperature sensor in 0,01°C
// Must be called before adding the EP to Zigbee class. Only effective in factory reset mode (before commissioning)
bool setDefaultValue(float defaultValue);

// Set the min and max value for the temperature sensor in 0,01°C
bool setMinMaxValue(float min, float max);

Expand All @@ -44,7 +48,7 @@ class ZigbeeTempSensor : public ZigbeeEP {
bool reportTemperature();

// Add humidity cluster to the temperature sensor device
void addHumiditySensor(float min, float max, float tolerance);
void addHumiditySensor(float min = 0.0, float max = 100.0, float tolerance = 0.1, float defaultValue = 0.0);

// Set the humidity value in 0,01%
bool setHumidity(float value);
Expand Down
Loading
Loading