Skip to content

[Draft] Thermostat - Relocate setpoint logic to separate file#42326

Draft
hasty wants to merge 9 commits intoproject-chip:masterfrom
hasty:granbery/cluster_driven_thermostat_setpoints
Draft

[Draft] Thermostat - Relocate setpoint logic to separate file#42326
hasty wants to merge 9 commits intoproject-chip:masterfrom
hasty:granbery/cluster_driven_thermostat_setpoints

Conversation

@hasty
Copy link
Copy Markdown
Contributor

@hasty hasty commented Dec 8, 2025

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.

@hasty hasty changed the title Granbery/cluster driven thermostat setpoints [HVAC] Thermostat - Relocate setpoint logic to separate file Dec 8, 2025
@mergify mergify bot added the conflict label Dec 8, 2025
@hasty hasty changed the title [HVAC] Thermostat - Relocate setpoint logic to separate file [Draft] Thermostat - Relocate setpoint logic to separate file Dec 8, 2025
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify mergify bot removed the conflict label Dec 8, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 8, 2025

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)
platform target config section efdf99d 99f09f4 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1105860 1105860 0 0.0
RAM 178954 178954 0 0.0
bl702 lighting-app bl702+eth FLASH 660680 660680 0 0.0
RAM 135025 135025 0 0.0
bl702+wifi FLASH 836530 836530 0 0.0
RAM 124485 124485 0 0.0
bl706+mfd+rpc+littlefs FLASH 1070174 1070174 0 0.0
RAM 117341 117341 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 902384 902384 0 0.0
RAM 105932 105932 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 982920 982920 0 0.0
RAM 109844 109844 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 770776 770776 0 0.0
RAM 103392 103392 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 783588 783588 0 0.0
RAM 108712 108712 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 728616 728616 0 0.0
RAM 97452 97452 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 713064 713064 0 0.0
RAM 97660 97660 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554588 554460 -128 -0.0
RAM 205472 205472 0 0.0
lock CC3235SF_LAUNCHXL FLASH 588528 588528 0 0.0
RAM 205720 205720 0 0.0
efr32 lock-app BRD4187C FLASH 964748 964748 0 0.0
RAM 123776 123776 0 0.0
BRD4338a FLASH 759072 759072 0 0.0
RAM 254388 254388 0 0.0
window-app BRD4187C FLASH 1059888 1059888 0 0.0
RAM 120004 120004 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1680956 1680956 0 0.0
RAM 214188 214188 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1595436 1595452 16 0.0
RAM 211364 211364 0 0.0
light cy8ckit_062s2_43012 FLASH 1460060 1460060 0 0.0
RAM 197800 197800 0 0.0
lock cy8ckit_062s2_43012 FLASH 1494004 1494004 0 0.0
RAM 225672 225672 0 0.0
qpg lighting-app qpg6200+debug FLASH 838248 838248 0 0.0
RAM 127984 127984 0 0.0
lock-app qpg6200+debug FLASH 775984 775984 0 0.0
RAM 118920 118920 0 0.0
realtek light-switch-app rtl8777g FLASH 708688 708688 0 0.0
RAM 107188 107188 0 0.0
lighting-app rtl8777g FLASH 757392 757392 0 0.0
RAM 127320 127320 0 0.0
stm32 light STM32WB5MM-DK FLASH 470244 470244 0 0.0
RAM 141392 141392 0 0.0
telink bridge-app tl7218x FLASH 703898 703898 0 0.0
RAM 90760 90760 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 790246 790246 0 0.0
RAM 41176 41176 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 781558 781558 0 0.0
RAM 93860 93860 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 710042 710042 0 0.0
RAM 52232 52232 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 745874 745874 0 0.0
RAM 71256 71256 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 720554 720554 0 0.0
RAM 34956 34956 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 602362 602362 0 0.0
RAM 117736 117736 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 815066 815070 4 0.0
RAM 92248 92248 0 0.0

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 8, 2025

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)
platform target config section efdf99d 18fd2e4 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1105860 1105616 -244 -0.0
RAM 178954 178970 16 0.0
bl702 lighting-app bl702+eth FLASH 660680 660708 28 0.0
RAM 135025 135041 16 0.0
bl702+wifi FLASH 836530 836292 -238 -0.0
RAM 124485 124501 16 0.0
bl706+mfd+rpc+littlefs FLASH 1070174 1070018 -156 -0.0
RAM 117341 117373 32 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 902384 902642 258 0.0
RAM 105932 105948 16 0.0
lighting-app bl702l+mfd+littlefs FLASH 982920 983020 100 0.0
RAM 109844 109876 32 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 770776 770680 -96 -0.0
RAM 103392 103400 8 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 783588 783692 104 0.0
RAM 108712 108728 16 0.0
pump-app LP_EM_CC1354P10_6 FLASH 728616 728708 92 0.0
RAM 97452 97468 16 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 713064 713284 220 0.0
RAM 97660 97676 16 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554588 554412 -176 -0.0
RAM 205472 205480 8 0.0
lock CC3235SF_LAUNCHXL FLASH 588528 588416 -112 -0.0
RAM 205720 205736 16 0.0
efr32 lock-app BRD4187C FLASH 964748 964880 132 0.0
RAM 123776 123808 32 0.0
BRD4338a FLASH 759072 759312 240 0.0
RAM 254388 254404 16 0.0
window-app BRD4187C FLASH 1059888 1060284 396 0.0
RAM 120004 120004 0 0.0
esp32 all-clusters-app c3devkit DRAM 102812 102820 8 0.0
FLASH 1830854 1830496 -358 -0.0
IRAM 93540 93540 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 936264 935964 -300 -0.0
RAM 161724 161736 12 0.0
nxp contact mcxw71+release FLASH 695104 695416 312 0.0
RAM 61744 61776 32 0.1
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1680956 1680884 -72 -0.0
RAM 214188 214204 16 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1595436 1595404 -32 -0.0
RAM 211364 211372 8 0.0
light cy8ckit_062s2_43012 FLASH 1460060 1460060 0 0.0
RAM 197800 197808 8 0.0
lock cy8ckit_062s2_43012 FLASH 1494004 1494140 136 0.0
RAM 225672 225688 16 0.0
qpg lighting-app qpg6200+debug FLASH 838248 837996 -252 -0.0
RAM 127984 127992 8 0.0
lock-app qpg6200+debug FLASH 775984 775980 -4 -0.0
RAM 118920 118944 24 0.0
realtek light-switch-app rtl8777g FLASH 708688 709000 312 0.0
RAM 107188 107204 16 0.0
lighting-app rtl8777g FLASH 757392 757408 16 0.0
RAM 127320 127336 16 0.0
stm32 light STM32WB5MM-DK FLASH 470244 470048 -196 -0.0
RAM 141392 141400 8 0.0
telink bridge-app tl7218x FLASH 703898 704336 438 0.1
RAM 90760 90772 12 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 790246 790494 248 0.0
RAM 41176 41208 32 0.1
light-app-ota-shell-factory-data tl7218x FLASH 781558 781858 300 0.0
RAM 93860 93872 12 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 710042 710474 432 0.1
RAM 52232 52244 12 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 745874 746306 432 0.1
RAM 71256 71268 12 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 720554 720960 406 0.1
RAM 34956 34972 16 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 602362 602602 240 0.0
RAM 117736 117768 32 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 815066 815380 314 0.0
RAM 92248 92260 12 0.0

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 9, 2025

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)
platform target config section 9a96230 8a7bc0a change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1105616 1105616 0 0.0
RAM 178970 178970 0 0.0
bl702 lighting-app bl702+eth FLASH 660708 660708 0 0.0
RAM 135041 135041 0 0.0
bl702+wifi FLASH 836292 836292 0 0.0
RAM 124501 124501 0 0.0
bl706+mfd+rpc+littlefs FLASH 1070018 1070018 0 0.0
RAM 117373 117373 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 902642 902642 0 0.0
RAM 105948 105948 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 983020 983020 0 0.0
RAM 109876 109876 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 770680 770680 0 0.0
RAM 103400 103400 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 783692 783692 0 0.0
RAM 108728 108728 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 728708 728708 0 0.0
RAM 97468 97468 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 713284 713284 0 0.0
RAM 97676 97676 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554540 554412 -128 -0.0
RAM 205480 205480 0 0.0
lock CC3235SF_LAUNCHXL FLASH 588416 588416 0 0.0
RAM 205736 205736 0 0.0
efr32 lock-app BRD4187C FLASH 964880 964880 0 0.0
RAM 123808 123808 0 0.0
BRD4338a FLASH 759312 759312 0 0.0
RAM 254404 254404 0 0.0
window-app BRD4187C FLASH 1060292 1060284 -8 -0.0
RAM 120004 120004 0 0.0
esp32 all-clusters-app c3devkit DRAM 102820 102820 0 0.0
FLASH 1830466 1830496 30 0.0
IRAM 93540 93540 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 936020 935964 -56 -0.0
RAM 161736 161736 0 0.0
nxp contact mcxw71+release FLASH 695416 695416 0 0.0
RAM 61776 61776 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1680884 1680884 0 0.0
RAM 214204 214204 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1595388 1595404 16 0.0
RAM 211372 211372 0 0.0
light cy8ckit_062s2_43012 FLASH 1460060 1460060 0 0.0
RAM 197808 197808 0 0.0
lock cy8ckit_062s2_43012 FLASH 1494140 1494140 0 0.0
RAM 225688 225688 0 0.0
qpg lighting-app qpg6200+debug FLASH 837996 837996 0 0.0
RAM 127992 127992 0 0.0
lock-app qpg6200+debug FLASH 775980 775980 0 0.0
RAM 118944 118944 0 0.0
realtek light-switch-app rtl8777g FLASH 709000 709000 0 0.0
RAM 107204 107204 0 0.0
lighting-app rtl8777g FLASH 757408 757408 0 0.0
RAM 127336 127336 0 0.0
stm32 light STM32WB5MM-DK FLASH 470048 470048 0 0.0
RAM 141400 141400 0 0.0
telink bridge-app tl7218x FLASH 704336 704336 0 0.0
RAM 90772 90772 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 790494 790494 0 0.0
RAM 41208 41208 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 781858 781858 0 0.0
RAM 93872 93872 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 710474 710474 0 0.0
RAM 52244 52244 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 746306 746306 0 0.0
RAM 71268 71268 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 720960 720960 0 0.0
RAM 34972 34972 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 602602 602602 0 0.0
RAM 117768 117768 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 815376 815380 4 0.0
RAM 92260 92260 0 0.0

@lboue
Copy link
Copy Markdown
Contributor

lboue commented Mar 14, 2026

Any news?

@mergify mergify bot added the conflict label Apr 11, 2026
@hasty hasty force-pushed the granbery/cluster_driven_thermostat_setpoints branch from bc1c1b7 to e9b7549 Compare April 11, 2026 18:13
@mergify mergify bot removed the conflict label Apr 11, 2026
@hasty hasty force-pushed the granbery/cluster_driven_thermostat_setpoints branch from e9b7549 to f5cbd69 Compare April 11, 2026 18:19
@github-actions
Copy link
Copy Markdown

PR #42326: Size comparison from a914062 to f5cbd69

Full report (3 builds for realtek, stm32)
platform target config section a914062 f5cbd69 change % change
realtek light-switch-app rtl8777g FLASH 680824 680824 0 0.0
RAM 101600 101600 0 0.0
lighting-app rtl8777g FLASH 724768 724768 0 0.0
RAM 101956 101956 0 0.0
stm32 light STM32WB5MM-DK FLASH 475468 475468 0 0.0
RAM 141388 141388 0 0.0

@hasty hasty force-pushed the granbery/cluster_driven_thermostat_setpoints branch 3 times, most recently from 41a0d50 to 18932e9 Compare April 11, 2026 20:27
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 11, 2026

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)
platform target config section a914062 18932e9 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1090510 1090510 0 0.0
RAM 144858 144858 0 0.0
bl616 lighting-app bl616+thread FLASH 1101988 1101988 0 0.0
RAM 104280 104280 0 0.0
bl616+wifi+shell FLASH 1588876 1588876 0 0.0
RAM 98176 98176 0 0.0
bl702 lighting-app bl702+eth FLASH 1053666 1053666 0 0.0
RAM 108461 108461 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 892364 892364 0 0.0
RAM 105852 105852 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 775904 775904 0 0.0
RAM 103396 103396 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788108 788108 0 0.0
RAM 108588 108588 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 734432 734432 0 0.0
RAM 97396 97396 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717860 717860 0 0.0
RAM 97556 97556 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 559874 559258 -616 -0.1
RAM 204568 204568 0 0.0
lock CC3235SF_LAUNCHXL FLASH 592742 592742 0 0.0
RAM 204816 204816 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1711836 1711492 -344 -0.0
RAM 214020 214020 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1609292 1608868 -424 -0.0
RAM 210908 210908 0 0.0
light cy8ckit_062s2_43012 FLASH 1466876 1466876 0 0.0
RAM 197068 197068 0 0.0
lock cy8ckit_062s2_43012 FLASH 1499596 1499596 0 0.0
RAM 224820 224820 0 0.0
qpg lighting-app qpg6200+debug FLASH 842684 842684 0 0.0
RAM 127868 127868 0 0.0
lock-app qpg6200+debug FLASH 781300 781300 0 0.0
RAM 118816 118816 0 0.0
realtek light-switch-app rtl8777g FLASH 680824 680824 0 0.0
RAM 101600 101600 0 0.0
lighting-app rtl8777g FLASH 724768 724768 0 0.0
RAM 101956 101956 0 0.0
stm32 light STM32WB5MM-DK FLASH 475468 475468 0 0.0
RAM 141388 141388 0 0.0
telink bridge-app tl7218x FLASH 730822 730822 0 0.0
RAM 95924 95924 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 850332 850332 0 0.0
RAM 44340 44340 0 0.0
tl7218x FLASH 841738 841738 0 0.0
RAM 99724 99724 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 730236 730236 0 0.0
RAM 55984 55984 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 793462 793462 0 0.0
RAM 75160 75160 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 730180 730180 0 0.0
RAM 33468 33468 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 613142 613142 0 0.0
RAM 118396 118396 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 839872 839876 4 0.0
RAM 97432 97432 0 0.0

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Codecov Report

❌ Patch coverage is 1.48760% with 596 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.35%. Comparing base (a914062) to head (9d5db83).

Files with missing lines Patch % Lines
src/app/clusters/thermostat-server/Setpoints.cpp 0.00% 218 Missing ⚠️
...p/clusters/thermostat-server/ThermostatCluster.cpp 4.05% 213 Missing ⚠️
...s/thermostat-server/ThermostatClusterSetpoints.cpp 0.00% 107 Missing ⚠️
.../app/clusters/thermostat-server/SetpointLimits.cpp 0.00% 17 Missing ⚠️
src/app/clusters/thermostat-server/Setpoints.h 0.00% 14 Missing ⚠️
...rc/app/clusters/thermostat-server/SetpointLimits.h 0.00% 12 Missing ⚠️
...ers/thermostat-server/ThermostatClusterPresets.cpp 0.00% 12 Missing ⚠️
src/app/clusters/thermostat-server/SetpointRange.h 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42326      +/-   ##
==========================================
+ Coverage   54.32%   54.35%   +0.02%     
==========================================
  Files        1577     1583       +6     
  Lines      108271   108218      -53     
  Branches    13401    13342      -59     
==========================================
  Hits        58820    58820              
+ Misses      49451    49398      -53     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hasty hasty force-pushed the granbery/cluster_driven_thermostat_setpoints branch 2 times, most recently from 0d736be to 4d0bf50 Compare April 11, 2026 21:37
@github-actions
Copy link
Copy Markdown

PR #42326: Size comparison from a914062 to 4d0bf50

Full report (5 builds for cc32xx, realtek, stm32)
platform target config section a914062 4d0bf50 change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 559874 559258 -616 -0.1
RAM 204568 204568 0 0.0
lock CC3235SF_LAUNCHXL FLASH 592742 592742 0 0.0
RAM 204816 204816 0 0.0
realtek light-switch-app rtl8777g FLASH 680824 680824 0 0.0
RAM 101600 101600 0 0.0
lighting-app rtl8777g FLASH 724768 724768 0 0.0
RAM 101956 101956 0 0.0
stm32 light STM32WB5MM-DK FLASH 475468 475468 0 0.0
RAM 141388 141388 0 0.0

@hasty hasty force-pushed the granbery/cluster_driven_thermostat_setpoints branch from 4d0bf50 to 2ff1353 Compare April 11, 2026 21:58
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 11, 2026

PR #42326: Size comparison from a914062 to 2ff1353

Full report (21 builds for bl602, bl616, bl702, bl702l, cc13x4_26x4, cc32xx, nrfconnect, psoc6, qpg, realtek, stm32)
platform target config section a914062 2ff1353 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1090510 1090510 0 0.0
RAM 144858 144858 0 0.0
bl616 lighting-app bl616+thread FLASH 1101988 1101988 0 0.0
RAM 104280 104280 0 0.0
bl616+wifi+shell FLASH 1588876 1588876 0 0.0
RAM 98176 98176 0 0.0
bl702 lighting-app bl702+eth FLASH 1053666 1053666 0 0.0
RAM 108461 108461 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 892364 892364 0 0.0
RAM 105852 105852 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 775904 775904 0 0.0
RAM 103396 103396 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788108 788108 0 0.0
RAM 108588 108588 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 734432 734432 0 0.0
RAM 97396 97396 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717860 717860 0 0.0
RAM 97556 97556 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 559874 559274 -600 -0.1
RAM 204568 204568 0 0.0
lock CC3235SF_LAUNCHXL FLASH 592742 592742 0 0.0
RAM 204816 204816 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 862472 861868 -604 -0.1
RAM 162090 162090 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1711836 1711508 -328 -0.0
RAM 214020 214020 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1609292 1608868 -424 -0.0
RAM 210908 210908 0 0.0
light cy8ckit_062s2_43012 FLASH 1466876 1466876 0 0.0
RAM 197068 197068 0 0.0
lock cy8ckit_062s2_43012 FLASH 1499596 1499596 0 0.0
RAM 224820 224820 0 0.0
qpg lighting-app qpg6200+debug FLASH 842684 842684 0 0.0
RAM 127868 127868 0 0.0
lock-app qpg6200+debug FLASH 781300 781300 0 0.0
RAM 118816 118816 0 0.0
realtek light-switch-app rtl8777g FLASH 680824 680824 0 0.0
RAM 101600 101600 0 0.0
lighting-app rtl8777g FLASH 724768 724768 0 0.0
RAM 101956 101956 0 0.0
stm32 light STM32WB5MM-DK FLASH 475468 475468 0 0.0
RAM 141388 141388 0 0.0

@hasty hasty force-pushed the granbery/cluster_driven_thermostat_setpoints branch from 2ff1353 to 9d5db83 Compare April 11, 2026 22:46
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 11, 2026

PR #42326: Size comparison from a914062 to 9d5db83

Full report (12 builds for cc13x4_26x4, cc32xx, nrfconnect, qpg, realtek, stm32)
platform target config section a914062 9d5db83 change % change
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 775904 775904 0 0.0
RAM 103396 103396 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788108 788108 0 0.0
RAM 108588 108588 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 734432 734432 0 0.0
RAM 97396 97396 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717860 717860 0 0.0
RAM 97556 97556 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 559874 559274 -600 -0.1
RAM 204568 204568 0 0.0
lock CC3235SF_LAUNCHXL FLASH 592742 592742 0 0.0
RAM 204816 204816 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 862472 861868 -604 -0.1
RAM 162090 162090 0 0.0
qpg lighting-app qpg6200+debug FLASH 842684 842684 0 0.0
RAM 127868 127868 0 0.0
lock-app qpg6200+debug FLASH 781300 781300 0 0.0
RAM 118816 118816 0 0.0
realtek light-switch-app rtl8777g FLASH 680824 680824 0 0.0
RAM 101600 101600 0 0.0
lighting-app rtl8777g FLASH 724768 724768 0 0.0
RAM 101956 101956 0 0.0
stm32 light STM32WB5MM-DK FLASH 475468 475468 0 0.0
RAM 141388 141388 0 0.0

@hasty hasty force-pushed the granbery/cluster_driven_thermostat_setpoints branch from 9d5db83 to a6edcdb Compare April 11, 2026 23:20
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 11, 2026

PR #42326: Size comparison from a914062 to a6edcdb

Full report (10 builds for cc13x4_26x4, cc32xx, nrfconnect, realtek, stm32)
platform target config section a914062 a6edcdb change % change
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 775904 775904 0 0.0
RAM 103396 103396 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788108 788108 0 0.0
RAM 108588 108588 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 734432 734432 0 0.0
RAM 97396 97396 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717860 717860 0 0.0
RAM 97556 97556 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 559874 559274 -600 -0.1
RAM 204568 204568 0 0.0
lock CC3235SF_LAUNCHXL FLASH 592742 592742 0 0.0
RAM 204816 204816 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 862472 861868 -604 -0.1
RAM 162090 162090 0 0.0
realtek light-switch-app rtl8777g FLASH 680824 680824 0 0.0
RAM 101600 101600 0 0.0
lighting-app rtl8777g FLASH 724768 724768 0 0.0
RAM 101956 101956 0 0.0
stm32 light STM32WB5MM-DK FLASH 475468 475468 0 0.0
RAM 141388 141388 0 0.0

@hasty hasty force-pushed the granbery/cluster_driven_thermostat_setpoints branch from a6edcdb to 5fa7767 Compare April 11, 2026 23:48
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 12, 2026

PR #42326: Size comparison from a914062 to 5fa7767

Full report (34 builds for bl602, bl616, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section a914062 5fa7767 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1090510 1090510 0 0.0
RAM 144858 144858 0 0.0
bl616 lighting-app bl616+thread FLASH 1101988 1101988 0 0.0
RAM 104280 104280 0 0.0
bl616+wifi+shell FLASH 1588876 1588876 0 0.0
RAM 98176 98176 0 0.0
bl702 lighting-app bl702+eth FLASH 1053666 1053666 0 0.0
RAM 108461 108461 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 892364 892364 0 0.0
RAM 105852 105852 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 775904 775904 0 0.0
RAM 103396 103396 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788108 788108 0 0.0
RAM 108588 108588 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 734432 734432 0 0.0
RAM 97396 97396 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717860 717860 0 0.0
RAM 97556 97556 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 559874 559242 -632 -0.1
RAM 204568 204568 0 0.0
lock CC3235SF_LAUNCHXL FLASH 592742 592742 0 0.0
RAM 204816 204816 0 0.0
efr32 lock-app BRD4187C FLASH 992512 992512 0 0.0
RAM 131268 131268 0 0.0
BRD4338a FLASH 796297 796297 0 0.0
RAM 243372 243372 0 0.0
window-app BRD4187C FLASH 1098000 1098000 0 0.0
RAM 130308 130308 0 0.0
esp32 all-clusters-app c3devkit DRAM 98460 98460 0 0.0
FLASH 1599144 1599200 56 0.0
IRAM 93514 93514 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 862472 861836 -636 -0.1
RAM 162090 162090 0 0.0
nxp contact mcxw71+release FLASH 739032 739032 0 0.0
RAM 67016 67016 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1711836 1711476 -360 -0.0
RAM 214020 214020 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1609292 1608852 -440 -0.0
RAM 210908 210908 0 0.0
light cy8ckit_062s2_43012 FLASH 1466876 1466876 0 0.0
RAM 197068 197068 0 0.0
lock cy8ckit_062s2_43012 FLASH 1499596 1499596 0 0.0
RAM 224820 224820 0 0.0
qpg lighting-app qpg6200+debug FLASH 842684 842684 0 0.0
RAM 127868 127868 0 0.0
lock-app qpg6200+debug FLASH 781300 781300 0 0.0
RAM 118816 118816 0 0.0
realtek light-switch-app rtl8777g FLASH 680824 680824 0 0.0
RAM 101600 101600 0 0.0
lighting-app rtl8777g FLASH 724768 724768 0 0.0
RAM 101956 101956 0 0.0
stm32 light STM32WB5MM-DK FLASH 475468 475468 0 0.0
RAM 141388 141388 0 0.0
telink bridge-app tl7218x FLASH 730822 730822 0 0.0
RAM 95924 95924 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 850332 850332 0 0.0
RAM 44340 44340 0 0.0
tl7218x FLASH 841738 841738 0 0.0
RAM 99724 99724 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 730236 730236 0 0.0
RAM 55984 55984 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 793462 793462 0 0.0
RAM 75160 75160 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 730180 730180 0 0.0
RAM 33468 33468 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 613142 613142 0 0.0
RAM 118396 118396 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 839872 839876 4 0.0
RAM 97432 97432 0 0.0

@hasty
Copy link
Copy Markdown
Contributor Author

hasty commented Apr 12, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Thermostat cluster server implementation, transitioning from a monolithic structure to a modular design with dedicated classes for setpoint and limit management. Key additions include the Setpoints and SetpointLimits components to handle complex validation and deadband logic. The review identifies critical architectural issues, specifically the performance of attribute writes within the PreAttributeChangedCallback, which violates the SDK's concurrency model and can lead to infinite recursion. Additionally, the AttributeAccessInterface implementation incorrectly returns success for unhandled attributes, which would prevent the system from falling back to the default attribute store. Other feedback highlights missing error propagation in the SetpointRaiseLower command, a potential specification violation regarding the default deadband value, and missing range validation for deadband updates.

}
if (status == Status::Success && affectedAttributes.HasAny())
{
status = SaveSetpoints(attributePath.mEndpointId, setpoints, affectedAttributes);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The HandleSetpointChange function is called from MatterThermostatClusterServerPreAttributeChangedCallback. Invoking SaveSetpoints here performs attribute writes, which are side effects. As noted in the comment at line 44 of ThermostatCluster.cpp, side effects are not permitted in the Pre callback. Performing writes here can lead to inconsistent state if the current change is later rejected, and it can cause infinite recursion as SaveSetpoints triggers further Pre callbacks. This logic should be moved to the Post callback (MatterThermostatClusterServerAttributeChangedCallback).

break;
}

return CHIP_NO_ERROR;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In an AttributeAccessInterface, returning CHIP_NO_ERROR indicates that the attribute was successfully handled and encoded. For attributes not handled by this interface (which should fall back to the default attribute store), it must return CHIP_ERROR_NOT_FOUND. Returning CHIP_NO_ERROR without encoding anything will lead to malformed responses or internal errors in the Interaction Model engine. This applies to the Write method as well (line 365).

    return CHIP_ERROR_NOT_FOUND;
References
  1. In ReadAttribute handlers, do not add redundant checks for attribute existence, as API contracts guarantee they are only called for existent paths. The only requirement is to not crash on an invalid read and return the appropriate status for handled vs unhandled paths.

Comment on lines +210 to +218
chip::BitFlags<SetpointAttributes> affectedAttributes;
status = setpoints.ChangeRange(range, heat, cool, affectedAttributes);
if (status == Status::Success)
{
return SaveSetpoints(endpointId, setpoints, affectedAttributes);
}
}

return Status::Success;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The function should return the actual status of the operation. If ChangeRange fails (e.g., due to deadband constraints), the error should be propagated to the caller rather than returning Status::Success.

        chip::BitFlags<SetpointAttributes> affectedAttributes;
        status = setpoints.ChangeRange(range, heat, cool, affectedAttributes);
        if (status == Status::Success)
        {
            return SaveSetpoints(endpointId, setpoints, affectedAttributes);
        }
    }

    return status;
References
  1. Always check the return value of initialization or logic functions that can fail to ensure robust operation and prevent unstable states.

constexpr int16_t kDefaultAbsMaxHeatSetpointLimit = 3000; // 30C (86 F) is the default
constexpr int16_t kDefaultAbsMinCoolSetpointLimit = 1600; // 16C (61 F) is the default
constexpr int16_t kDefaultAbsMaxCoolSetpointLimit = 3200; // 32C (90 F) is the default
constexpr int16_t kDefaultDeadBand = 200; // 2.0C is the default
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The default value for MinSetpointDeadBand is changed from 25 (2.5°C) to 20 (2.0°C). According to the Matter specification (e.g., v1.3, Section 4.3.8.14), the default value for this attribute is 25. Changing this default may cause compliance issues or unexpected behavior for clients expecting the standard default value.

#define FEATURE_MAP_SB 0x10
#define FEATURE_MAP_AUTO 0x20

#define FEATURE_MAP_DEFAULT FEATURE_MAP_HEAT | FEATURE_MAP_COOL | FEATURE_MAP_AUTO
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is safer to wrap the macro definition in parentheses to avoid potential operator precedence issues when used in expressions.

#define FEATURE_MAP_DEFAULT (FEATURE_MAP_HEAT | FEATURE_MAP_COOL | FEATURE_MAP_AUTO)

Comment on lines +131 to +133
case MinSetpointDeadBand::Id: {
return Status::Success;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The HandleSetpointChange for MinSetpointDeadBand currently performs no validation. The previous implementation checked if the value was within the valid range (0-127) and if AutoMode was supported. Additionally, changing the deadband might require re-validating or adjusting existing setpoints to maintain the new deadband constraint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants