Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc6b7dca

Browse files
P-R-O-C-H-Ypre-commit-ci-lite[bot]lucasssvaz
authored
feat(zigbee): Add option to set initial (default) value (#12147)
* feat(zigbee): Add option to set initial (default) value* feat(zigbee): Update temp examples* ci(pre-commit): Apply automatic fixes---------Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>Co-authored-by: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com>
1 parent1e52aa5 commitc6b7dca

23 files changed

+229
-5
lines changed

‎docs/en/zigbee/ep_carbon_dioxide_sensor.rst‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ Sets the minimum and maximum measurement values.
5454

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

57+
setDefaultValue
58+
^^^^^^^^^^^^^^^
59+
60+
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.
61+
62+
..code-block::arduino
63+
64+
bool setDefaultValue(float defaultValue);
65+
66+
* ``defaultValue`` - Default CO2 concentration value in ppm
67+
68+
**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).
69+
70+
This function will return ``true`` if successful, ``false`` otherwise.
71+
5772
setTolerance
5873
^^^^^^^^^^^^
5974

‎docs/en/zigbee/ep_flow_sensor.rst‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ Sets the minimum and maximum measurement values.
7070

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

73+
setDefaultValue
74+
^^^^^^^^^^^^^^^
75+
76+
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.
77+
78+
..code-block::arduino
79+
80+
bool setDefaultValue(float defaultValue);
81+
82+
* ``defaultValue`` - Default flow rate value in 0.1 m³/h
83+
84+
**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).
85+
86+
This function will return ``true`` if successful, ``false`` otherwise.
87+
7388
setTolerance
7489
^^^^^^^^^^^^
7590

‎docs/en/zigbee/ep_illuminance_sensor.rst‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ Sets the minimum and maximum measurement values.
6060

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

63+
setDefaultValue
64+
^^^^^^^^^^^^^^^
65+
66+
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.
67+
68+
..code-block::arduino
69+
70+
bool setDefaultValue(uint16_t defaultValue);
71+
72+
* ``defaultValue`` - Default illuminance value in lux
73+
74+
**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).
75+
76+
This function will return ``true`` if successful, ``false`` otherwise.
77+
6378
setTolerance
6479
^^^^^^^^^^^^
6580

‎docs/en/zigbee/ep_pm25_sensor.rst‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ Sets the minimum and maximum measurement values.
6060

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

63+
setDefaultValue
64+
^^^^^^^^^^^^^^^
65+
66+
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.
67+
68+
..code-block::arduino
69+
70+
bool setDefaultValue(float defaultValue);
71+
72+
* ``defaultValue`` - Default PM2.5 concentration value in 0.1 μg/m³
73+
74+
**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).
75+
76+
This function will return ``true`` if successful, ``false`` otherwise.
77+
6378
setTolerance
6479
^^^^^^^^^^^^
6580

‎docs/en/zigbee/ep_pressure_sensor.rst‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ Sets the minimum and maximum measurement values.
6060

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

63+
setDefaultValue
64+
^^^^^^^^^^^^^^^
65+
66+
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.
67+
68+
..code-block::arduino
69+
70+
bool setDefaultValue(int16_t defaultValue);
71+
72+
* ``defaultValue`` - Default pressure value in hPa
73+
74+
**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).
75+
76+
This function will return ``true`` if successful, ``false`` otherwise.
77+
6378
setTolerance
6479
^^^^^^^^^^^^
6580

‎docs/en/zigbee/ep_temperature_sensor.rst‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ Sets the minimum and maximum temperature values for the sensor.
6060

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

63+
setDefaultValue
64+
^^^^^^^^^^^^^^^
65+
66+
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.
67+
68+
..code-block::arduino
69+
70+
bool setDefaultValue(float defaultValue);
71+
72+
* ``defaultValue`` - Default temperature value in degrees Celsius
73+
74+
**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).
75+
76+
This function will return ``true`` if successful, ``false`` otherwise.
77+
6378
setTolerance
6479
^^^^^^^^^^^^
6580

‎docs/en/zigbee/ep_wind_speed_sensor.rst‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ Sets the minimum and maximum measurement values.
7070

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

73+
setDefaultValue
74+
^^^^^^^^^^^^^^^
75+
76+
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.
77+
78+
..code-block::arduino
79+
80+
bool setDefaultValue(float defaultValue);
81+
82+
* ``defaultValue`` - Default wind speed value in 0.01 m/s
83+
84+
**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).
85+
86+
This function will return ``true`` if successful, ``false`` otherwise.
87+
7388
setTolerance
7489
^^^^^^^^^^^^
7590

‎libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/Zigbee_Temp_Hum_Sensor_Sleepy.ino‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,18 @@ void setup() {
135135
// Set minimum and maximum temperature measurement value (10-50°C is default range for chip temperature measurement)
136136
zbTempSensor.setMinMaxValue(10,50);
137137

138+
// 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)
139+
zbTempSensor.setDefaultValue(10.0);
140+
138141
// Set tolerance for temperature measurement in °C (lowest possible value is 0.01°C)
139142
zbTempSensor.setTolerance(1);
140143

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

145-
// Add humidity cluster to the temperature sensor device with min, maxandtolerance values
146-
zbTempSensor.addHumiditySensor(0,100,1);
148+
// Add humidity cluster to the temperature sensor device with min, max, toleranceanddefault values
149+
zbTempSensor.addHumiditySensor(0,100,1,0.0);
147150

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

‎libraries/Zigbee/examples/Zigbee_Temperature_Sensor/Zigbee_Temperature_Sensor.ino‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ void setup() {
6868
// Set minimum and maximum temperature measurement value (10-50°C is default range for chip temperature measurement)
6969
zbTempSensor.setMinMaxValue(10,50);
7070

71+
// Optional: Set default (initial) value for the temperature sensor to 10.0°C to match the minimum temperature measurement value
72+
zbTempSensor.setDefaultValue(10.0);
73+
7174
// Optional: Set tolerance for temperature measurement in °C (lowest possible value is 0.01°C)
7275
zbTempSensor.setTolerance(1);
7376

‎libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.cpp‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ ZigbeeCarbonDioxideSensor::ZigbeeCarbonDioxideSensor(uint8_t endpoint) : ZigbeeE
3838
_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};
3939
}
4040

41+
boolZigbeeCarbonDioxideSensor::setDefaultValue(float defaultValue) {
42+
float zb_default_value = defaultValue /1000000.0f;
43+
esp_zb_attribute_list_t *carbon_dioxide_measure_cluster =
44+
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_CARBON_DIOXIDE_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
45+
esp_err_t ret =
46+
esp_zb_cluster_update_attr(carbon_dioxide_measure_cluster, ESP_ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MEASURED_VALUE_ID, (void *)&zb_default_value);
47+
if (ret != ESP_OK) {
48+
log_e("Failed to set default value: 0x%x: %s", ret,esp_err_to_name(ret));
49+
returnfalse;
50+
}
51+
returntrue;
52+
}
53+
4154
boolZigbeeCarbonDioxideSensor::setMinMaxValue(float min,float max) {
4255
float zb_min = min /1000000.0f;
4356
float zb_max = max /1000000.0f;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp