-
Notifications
You must be signed in to change notification settings - Fork 7.8k
feat(zigbee): Add option to set initial (default) value #12147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Hello P-R-O-C-H-Y, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds support for setting default (initial) measurement values for Zigbee sensor endpoints, ensuring predictable behavior after factory reset and before sensors receive actual readings. The implementation extends seven sensor classes with new setDefaultValue methods, updates documentation, and modifies example code to demonstrate the feature.
Key changes:
- Added
setDefaultValuemethods to seven sensor classes (Temperature, CO2, Flow, Illuminance, PM2.5, Pressure, and Wind Speed) - Updated
addHumiditySensormethod to accept a default value parameter with backward-compatible default arguments - Enhanced documentation with comprehensive descriptions of the new functionality
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| libraries/Zigbee/src/ep/ZigbeeTempSensor.h | Added setDefaultValue method declaration for temperature sensor |
| libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp | Implemented setDefaultValue with proper int16_t conversion; added default value to addHumiditySensor signature; constructor now calls setDefaultValue(0.0) |
| libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.h | Added setDefaultValue method declaration for wind speed sensor |
| libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.cpp | Implemented setDefaultValue with uint16_t conversion |
| libraries/Zigbee/src/ep/ZigbeeFlowSensor.h | Added setDefaultValue method declaration for flow sensor |
| libraries/Zigbee/src/ep/ZigbeeFlowSensor.cpp | Implemented setDefaultValue with uint16_t conversion |
| libraries/Zigbee/src/ep/ZigbeeIlluminanceSensor.h | Added setDefaultValue method declaration for illuminance sensor |
| libraries/Zigbee/src/ep/ZigbeeIlluminanceSensor.cpp | Implemented setDefaultValue for uint16_t values |
| libraries/Zigbee/src/ep/ZigbeePM25Sensor.h | Added setDefaultValue method declaration for PM2.5 sensor |
| libraries/Zigbee/src/ep/ZigbeePM25Sensor.cpp | Implemented setDefaultValue using float type directly |
| libraries/Zigbee/src/ep/ZigbeePressureSensor.h | Added setDefaultValue method declaration for pressure sensor |
| libraries/Zigbee/src/ep/ZigbeePressureSensor.cpp | Implemented setDefaultValue for int16_t values |
| libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.h | Added setDefaultValue method declaration for CO2 sensor |
| libraries/Zigbee/src/ep/ZigbeeCarbonDioxideSensor.cpp | Implemented setDefaultValue with float conversion (divide by 1,000,000) |
| libraries/Zigbee/examples/Zigbee_Temperature_Sensor/Zigbee_Temperature_Sensor.ino | Added example call to setDefaultValue(10.0) |
| libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/Zigbee_Temp_Hum_Sensor_Sleepy.ino | Updated to demonstrate setDefaultValue for temperature and updated addHumiditySensor call with default value parameter |
| docs/en/zigbee/ep_temperature_sensor.rst | Added documentation for setDefaultValue method |
| docs/en/zigbee/ep_wind_speed_sensor.rst | Added documentation for setDefaultValue method |
| docs/en/zigbee/ep_pressure_sensor.rst | Added documentation for setDefaultValue method |
| docs/en/zigbee/ep_pm25_sensor.rst | Added documentation for setDefaultValue method |
| docs/en/zigbee/ep_illuminance_sensor.rst | Added documentation for setDefaultValue method |
| docs/en/zigbee/ep_flow_sensor.rst | Added documentation for setDefaultValue method |
| docs/en/zigbee/ep_carbon_dioxide_sensor.rst | Added documentation for setDefaultValue method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Test Results 90 files 90 suites 33m 12s ⏱️ For more details on these failures, see this check. Results for commit 53e672e. |
Description of Change
This pull request introduces support for setting default (initial) measurement values for various Zigbee sensor endpoint classes, ensuring that sensors start with a defined value after a factory reset and before receiving actual readings. The changes include new
setDefaultValuemethods for several sensor types, updates to documentation, and adjustments to example usage to demonstrate the new functionality.Core feature: Default value support for Zigbee sensors
setDefaultValuemethods to the following sensor classes, allowing users to set an initial measurement value to be used after a factory reset and before the sensor reports real data:ZigbeeTempSensor,ZigbeeCarbonDioxideSensor,ZigbeeFlowSensor,ZigbeeIlluminanceSensor,ZigbeePM25Sensor,ZigbeePressureSensor, andZigbeeWindSpeedSensor(libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp,ZigbeeCarbonDioxideSensor.cpp,ZigbeeFlowSensor.cpp,ZigbeeIlluminanceSensor.cpp,ZigbeePM25Sensor.cpp,ZigbeePressureSensor.cpp,ZigbeeWindSpeedSensor.cpp; corresponding.hfiles) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]Documentation updates
setDefaultValuemethod, its usage, and its effect during factory reset (before commissioning or joining a network) (docs/en/zigbee/ep_temperature_sensor.rst,ep_carbon_dioxide_sensor.rst,ep_flow_sensor.rst,ep_illuminance_sensor.rst,ep_pm25_sensor.rst,ep_pressure_sensor.rst,ep_wind_speed_sensor.rst) [1] [2] [3] [4] [5] [6] [7]Example usage improvements
addHumiditySensormethod to accept a default value parameter (libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/Zigbee_Temp_Hum_Sensor_Sleepy.ino,Zigbee_Temperature_Sensor.ino,ZigbeeTempSensor.cpp) [1] [2] [3]These changes make it easier to ensure predictable sensor behavior after a factory reset and improve the clarity and usability of the sensor API.
Test Scenarios
Tested using the Temperature sensor example and HomeAssitant (ZHA)
Related links
Closes #12041