-
Notifications
You must be signed in to change notification settings - Fork 7.7k
feat(zigbee): Add humidity support for Thermostat + TempSensor fix #11940
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 ...
|
Test Results 76 files 76 suites 15m 52s ⏱️ Results for commit 1ab7203. ♻️ This comment has been updated with latest results. |
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]
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Docs LGTM! Thanks!
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 PR adds humidity measurement support to the ZigbeeThermostat endpoint and refactors temperature-related methods for improved clarity. The changes maintain backward compatibility through deprecated aliases.
Key changes:
- Added comprehensive humidity measurement APIs mirroring existing temperature functionality
- Renamed temperature methods from generic names (e.g.,
getSensorSettings) to specific ones (e.g.,getTemperatureSettings) - Fixed data type consistency in humidity handling (changed from
int16_ttouint16_t)
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| libraries/Zigbee/src/ep/ZigbeeThermostat.h | Added humidity callbacks and methods; renamed temperature methods with deprecated aliases |
| libraries/Zigbee/src/ep/ZigbeeThermostat.cpp | Implemented humidity cluster binding and all humidity-related methods |
| libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp | Fixed humidity data type from signed to unsigned with proper conversion |
| libraries/Zigbee/keywords.txt | Updated keywords to reflect new humidity methods and renamed temperature methods |
| libraries/Zigbee/examples/Zigbee_Thermostat/Zigbee_Thermostat.ino | Updated example to use new temperature method names |
| docs/en/zigbee/ep_thermostat.rst | Added documentation for all humidity APIs and updated temperature method names |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| log_d("Received min humidity: %.2f% from endpoint %d", _min_humidity, src_endpoint); | ||
| } | ||
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | ||
| uint16_t max_value = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | ||
| _max_humidity = 1.0 * max_value / 100; | ||
| read_humidity_config++; | ||
| log_d("Received max humidity: %.2f% from endpoint %d", _max_humidity, src_endpoint); | ||
| } | ||
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_TOLERANCE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | ||
| uint16_t tolerance = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | ||
| _tolerance_humidity = 1.0 * tolerance / 100; | ||
| read_humidity_config++; | ||
| log_d("Received tolerance: %.2f% from endpoint %d", _tolerance_humidity, src_endpoint); |
Copilot
AI
Oct 25, 2025
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.
Format strings incorrectly show '%.2f%' which will display values like '50.00%'. Should be '%.2f%%' to properly escape the percent sign for values like '50.00%'.
| log_d("Received min humidity: %.2f% from endpoint %d", _min_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t max_value = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _max_humidity = 1.0 * max_value / 100; | |
| read_humidity_config++; | |
| log_d("Received max humidity: %.2f% from endpoint %d", _max_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_TOLERANCE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t tolerance = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _tolerance_humidity = 1.0 * tolerance / 100; | |
| read_humidity_config++; | |
| log_d("Received tolerance: %.2f% from endpoint %d", _tolerance_humidity, src_endpoint); | |
| log_d("Received min humidity: %.2f%% from endpoint %d", _min_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t max_value = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _max_humidity = 1.0 * max_value / 100; | |
| read_humidity_config++; | |
| log_d("Received max humidity: %.2f%% from endpoint %d", _max_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_TOLERANCE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t tolerance = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _tolerance_humidity = 1.0 * tolerance / 100; | |
| read_humidity_config++; | |
| log_d("Received tolerance: %.2f%% from endpoint %d", _tolerance_humidity, src_endpoint); |
| log_d("Received min humidity: %.2f% from endpoint %d", _min_humidity, src_endpoint); | ||
| } | ||
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | ||
| uint16_t max_value = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | ||
| _max_humidity = 1.0 * max_value / 100; | ||
| read_humidity_config++; | ||
| log_d("Received max humidity: %.2f% from endpoint %d", _max_humidity, src_endpoint); | ||
| } | ||
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_TOLERANCE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | ||
| uint16_t tolerance = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | ||
| _tolerance_humidity = 1.0 * tolerance / 100; | ||
| read_humidity_config++; | ||
| log_d("Received tolerance: %.2f% from endpoint %d", _tolerance_humidity, src_endpoint); |
Copilot
AI
Oct 25, 2025
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.
Format strings incorrectly show '%.2f%' which will display values like '50.00%'. Should be '%.2f%%' to properly escape the percent sign for values like '50.00%'.
| log_d("Received min humidity: %.2f% from endpoint %d", _min_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t max_value = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _max_humidity = 1.0 * max_value / 100; | |
| read_humidity_config++; | |
| log_d("Received max humidity: %.2f% from endpoint %d", _max_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_TOLERANCE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t tolerance = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _tolerance_humidity = 1.0 * tolerance / 100; | |
| read_humidity_config++; | |
| log_d("Received tolerance: %.2f% from endpoint %d", _tolerance_humidity, src_endpoint); | |
| log_d("Received min humidity: %.2f%% from endpoint %d", _min_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t max_value = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _max_humidity = 1.0 * max_value / 100; | |
| read_humidity_config++; | |
| log_d("Received max humidity: %.2f%% from endpoint %d", _max_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_TOLERANCE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t tolerance = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _tolerance_humidity = 1.0 * tolerance / 100; | |
| read_humidity_config++; | |
| log_d("Received tolerance: %.2f%% from endpoint %d", _tolerance_humidity, src_endpoint); |
| log_d("Received min humidity: %.2f% from endpoint %d", _min_humidity, src_endpoint); | ||
| } | ||
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | ||
| uint16_t max_value = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | ||
| _max_humidity = 1.0 * max_value / 100; | ||
| read_humidity_config++; | ||
| log_d("Received max humidity: %.2f% from endpoint %d", _max_humidity, src_endpoint); | ||
| } | ||
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_TOLERANCE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | ||
| uint16_t tolerance = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | ||
| _tolerance_humidity = 1.0 * tolerance / 100; | ||
| read_humidity_config++; | ||
| log_d("Received tolerance: %.2f% from endpoint %d", _tolerance_humidity, src_endpoint); |
Copilot
AI
Oct 25, 2025
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.
Format strings incorrectly show '%.2f%' which will display values like '50.00%'. Should be '%.2f%%' to properly escape the percent sign for values like '50.00%'.
| log_d("Received min humidity: %.2f% from endpoint %d", _min_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t max_value = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _max_humidity = 1.0 * max_value / 100; | |
| read_humidity_config++; | |
| log_d("Received max humidity: %.2f% from endpoint %d", _max_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_TOLERANCE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t tolerance = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _tolerance_humidity = 1.0 * tolerance / 100; | |
| read_humidity_config++; | |
| log_d("Received tolerance: %.2f% from endpoint %d", _tolerance_humidity, src_endpoint); | |
| log_d("Received min humidity: %.2f%% from endpoint %d", _min_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t max_value = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _max_humidity = 1.0 * max_value / 100; | |
| read_humidity_config++; | |
| log_d("Received max humidity: %.2f%% from endpoint %d", _max_humidity, src_endpoint); | |
| } | |
| if (attribute->id == ESP_ZB_ZCL_ATTR_REL_HUMIDITY_TOLERANCE_ID && attribute->data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { | |
| uint16_t tolerance = attribute->data.value ? *(uint16_t *)attribute->data.value : 0; | |
| _tolerance_humidity = 1.0 * tolerance / 100; | |
| read_humidity_config++; | |
| log_d("Received tolerance: %.2f%% from endpoint %d", _tolerance_humidity, src_endpoint); |
Description of Change
This pull request introduces improvements to the
ZigbeeThermostatEP, primarily by expanding support for humidity measurement and refactoring temperature configuration methods for clarity and consistency. The changes also ensure backward compatibility for deprecated methods.Refactoring and Backward Compatibility
ZigbeeThermostatto useonTempConfigReceiveandgetTemperatureSettingsinstead of the olderonConfigReceiveandgetSensorSettings. Deprecated methods now act as aliases to the new ones to maintain backward compatibility. (libraries/Zigbee/src/ep/ZigbeeThermostat.h,libraries/Zigbee/examples/Zigbee_Thermostat/Zigbee_Thermostat.ino,libraries/Zigbee/keywords.txt) [1] [2] [3] [4]Humidity Measurement Feature
ZigbeeThermostat, including new callback setters, getter and setter methods, configuration retrieval, and reporting functions. Also updated the keywords file to reflect these additions. (libraries/Zigbee/src/ep/ZigbeeThermostat.h,libraries/Zigbee/keywords.txt) [1] [2]Data Type Consistency
int16_ttouint16_tand updated conversion logic to multiply by 100 for precision, ensuring consistency with Zigbee cluster attribute requirements. (libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp) [1] [2]These changes make the codebase easier to maintain, extend functionality for humidity sensors, and ensure smooth migration for existing users of the temperature sensor API.
Test Scenarios
Tested using two ESP32-C6 with following examples:
Temp + Humidity sensor - ED:
Thermostat - Coordinator:
Related links
Closes #11665