Thermostat - Relocate setpoint logic to separate files#42326
Conversation
…ter tests to change it
…r_driven_thermostat
There was a problem hiding this comment.
Code Review
This pull request successfully refactors the Thermostat cluster by moving setpoint-related logic into new dedicated files, ThermostatClusterSetpoints.cpp and ThermostatClusterSetpoints.h. This improves modularity and prepares for a code-driven cluster implementation. The changes also include updating the default value for minSetpointDeadBand across various examples and tests, which is a good consistency improvement. My review includes suggestions to further improve the refactoring by using the new GetSetpointLimits helper function in a couple of places where limit attributes are still being fetched manually, aligning with the rule to extract common logic into helper functions. This will make the code cleaner and more consistent.
|
PR #42326: Size comparison from efdf99d to 99f09f4 Full report (32 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, psoc6, qpg, realtek, stm32, telink)
|
…driven_thermostat # Conflicts: # examples/all-clusters-app/linux/main-common.cpp
|
PR #42326: Size comparison from efdf99d to 18fd2e4 Full report (35 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
|
|
PR #42326: Size comparison from 9a96230 to 8a7bc0a Full report (35 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
|
|
Any news? |
bc1c1b7 to
e9b7549
Compare
e9b7549 to
f5cbd69
Compare
|
PR #42326: Size comparison from a914062 to f5cbd69 Full report (3 builds for realtek, stm32)
|
41a0d50 to
18932e9
Compare
|
PR #42326: Size comparison from a914062 to 18932e9 Full report (28 builds for bl602, bl616, bl702, bl702l, cc13x4_26x4, cc32xx, psoc6, qpg, realtek, stm32, telink)
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #42326 +/- ##
==========================================
- Coverage 56.61% 56.56% -0.05%
==========================================
Files 1642 1651 +9
Lines 113137 113228 +91
Branches 13243 13237 -6
==========================================
+ Hits 64048 64049 +1
- Misses 49089 49179 +90 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
18932e9 to
0d736be
Compare
|
PR #42326: Size comparison from ca3e67c to b419229 Full report (35 builds for bl602, bl616, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, psoc6, qpg, realtek, stm32, telink)
|
There was a problem hiding this comment.
Code Review
This pull request refactors the thermostat server cluster by introducing a modular, object-oriented setpoint management architecture (including Setpoint, SetpointLimits, and Setpoints classes) to replace legacy procedural validation logic, alongside updating Python test suites to use a simulated thermostat state. The review feedback highlights several critical and high-severity issues: a potential crash in OptionalSetpoint::Encode when calling .Value() on an uninitialized optional, unsafe downcasting in isEqual that should be replaced with a safe base-class operator==, redundant temperature casts in Setpoints::Valid that risk signed integer overflow, and redundant conditional checks in SetpointRaiseLower that can be simplified.
| if (mTemperature.HasValue()) | ||
| return mTemperature.Value(); |
There was a problem hiding this comment.
Not sure if we have a requirement for this, but might be worth adding the brackets just to be consistent?
There was a problem hiding this comment.
| if (mTemperature.HasValue()) | |
| return mTemperature.Value(); | |
| if (mTemperature.HasValue()) | |
| { | |
| return mTemperature.Value(); | |
| } |
There was a problem hiding this comment.
It does not look like it got sorted?
There was a problem hiding this comment.
Fixed in a different place, but now fixed in both.
for more information, see https://pre-commit.ci
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the thermostat cluster server's setpoint handling by introducing a structured Setpoints class and associated helper classes to manage validation, limits, and deadband enforcement. It also updates the corresponding Python tests to utilize a simulator matching this new logic. The review feedback identifies several critical issues that must be addressed: bugs in Setpoints::Valid() and Setpoints::FixUserLimits() that break compatibility with devices not supporting optional setpoint attributes, a compilation error in ThermostatCluster.cpp caused by referencing the non-existent chip::Encoding::Get8 function, and a code smell in Setpoint.h involving a reference member in a copy-assigned class that should be refactored to a pointer.
for more information, see https://pre-commit.ci
|
PR #42326: Size comparison from f4d8ecb to d65e4cd Full report (30 builds for cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, psoc6, qpg, realtek, stm32, telink)
|
Summary
This PR moves the setpoint functionality of the Thermostat cluster into a separate file, in preparation for migrating to a code-driven-cluster implementation of Thermostat.
Related issues
This is meant to be merged after #41739 and #41772.
Testing
Ran test suite.