Skip to content

Conversation

@P-R-O-C-H-Y
Copy link
Member

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 setDefaultValue methods 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

  • Added setDefaultValue methods 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, and ZigbeeWindSpeedSensor (libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp, ZigbeeCarbonDioxideSensor.cpp, ZigbeeFlowSensor.cpp, ZigbeeIlluminanceSensor.cpp, ZigbeePM25Sensor.cpp, ZigbeePressureSensor.cpp, ZigbeeWindSpeedSensor.cpp; corresponding .h files) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]

Documentation updates

  • Updated documentation for all affected sensor endpoint types to describe the new setDefaultValue method, 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

  • Updated example sketches to demonstrate setting a default value for temperature and humidity sensors, including changes to the addHumiditySensor method 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

@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this Dec 17, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y added Status: Review needed Issue or PR is awaiting review Area: Zigbee Issues and Feature Request about Zigbee labels Dec 17, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

Messages
📖 🎉 Good Job! All checks are passing!

👋 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 ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against a510d79

Copy link
Contributor

Copilot AI left a 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 setDefaultValue methods to seven sensor classes (Temperature, CO2, Flow, Illuminance, PM2.5, Pressure, and Wind Speed)
  • Updated addHumiditySensor method 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.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

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.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP32C5000.000.00000.000.00
ESP32S3000.000.00000.000.00
ESP32S20⚠️ +1960.00⚠️ +0.03000.000.00
ESP32C3000.000.00000.000.00
ESP32C6000.000.00000.000.00
ESP32H20⚠️ +1680.00⚠️ +0.03000.000.00
ESP320⚠️ +2000.00⚠️ +0.03000.000.00
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32C5ESP32S3ESP32S2ESP32C3ESP32C6ESP32H2ESP32
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
libraries/Zigbee/examples/Zigbee_Analog_Input_Output----⚠️ +196000--00⚠️ +1960
libraries/Zigbee/examples/Zigbee_Binary_Input_Output----------00--
libraries/Zigbee/examples/Zigbee_CarbonDioxide_Sensor----------00--
libraries/Zigbee/examples/Zigbee_Color_Dimmable_Light----------00--
libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch----⚠️ +196000--00⚠️ +1960
libraries/Zigbee/examples/Zigbee_Contact_Switch----------00--
libraries/Zigbee/examples/Zigbee_Dimmable_Light----------00--
libraries/Zigbee/examples/Zigbee_Electrical_AC_Sensor----⚠️ +196000--00⚠️ +2000
libraries/Zigbee/examples/Zigbee_Electrical_AC_Sensor_MultiPhase----⚠️ +196000--00⚠️ +2000
libraries/Zigbee/examples/Zigbee_Electrical_DC_Sensor----------00--
libraries/Zigbee/examples/Zigbee_Fan_Control----⚠️ +196000--00⚠️ +1960
libraries/Zigbee/examples/Zigbee_Gateway----⚠️ +196000----⚠️ +1960
libraries/Zigbee/examples/Zigbee_Illuminance_Sensor----------00--
libraries/Zigbee/examples/Zigbee_Multistate_Input_Output----⚠️ +196000--00⚠️ +1960
libraries/Zigbee/examples/Zigbee_OTA_Client----------00--
libraries/Zigbee/examples/Zigbee_Occupancy_Sensor----------00--
libraries/Zigbee/examples/Zigbee_On_Off_Light----------00--
libraries/Zigbee/examples/Zigbee_On_Off_MultiSwitch----⚠️ +196000--00⚠️ +1960
libraries/Zigbee/examples/Zigbee_On_Off_Switch----⚠️ +196000--00⚠️ +1960
libraries/Zigbee/examples/Zigbee_PM25_Sensor----------00--
libraries/Zigbee/examples/Zigbee_Power_Outlet----⚠️ +196000--00⚠️ +1960
libraries/Zigbee/examples/Zigbee_Pressure_Flow_Sensor----------00--
libraries/Zigbee/examples/Zigbee_Range_Extender----⚠️ +196000--00⚠️ +1960
libraries/Zigbee/examples/Zigbee_Scan_Networks----------00--
libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy----------⚠️ +1680--
libraries/Zigbee/examples/Zigbee_Temperature_Sensor----------⚠️ +1340--
libraries/Zigbee/examples/Zigbee_Thermostat----⚠️ +196000--00⚠️ +1960
libraries/Zigbee/examples/Zigbee_Vibration_Sensor----------00--
libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor----------00--

@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

Test Results

 90 files   90 suites   32m 5s ⏱️
 66 tests  66 ✅ 0 💤 0 ❌
675 runs  675 ✅ 0 💤 0 ❌

Results for commit a510d79.

♻️ This comment has been updated with latest results.

@me-no-dev me-no-dev added Status: Pending Merge Pull Request is ready to be merged and removed Status: Review needed Issue or PR is awaiting review labels Dec 18, 2025
@me-no-dev me-no-dev merged commit c6b7dca into master Dec 18, 2025
80 checks passed
@me-no-dev me-no-dev deleted the feat/zibee-sensor-default-value branch December 18, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Zigbee Issues and Feature Request about Zigbee Status: Pending Merge Pull Request is ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Temperature and humidity sensor has garbage after starting ESP32C6

5 participants