Skip to content

fix(thermostat-server): notify subscribers when ActivePresetHandle changes#43583

Open
lboue wants to merge 2 commits intoproject-chip:masterfrom
lboue:fix/ActivePresetHandle-subscription-report
Open

fix(thermostat-server): notify subscribers when ActivePresetHandle changes#43583
lboue wants to merge 2 commits intoproject-chip:masterfrom
lboue:fix/ActivePresetHandle-subscription-report

Conversation

@lboue
Copy link
Contributor

@lboue lboue commented Mar 13, 2026

Summary

SetActivePreset() was updating the ActivePresetHandle attribute via the delegate but not calling MatterReportingAttributeChangeCallback() afterwards. As a result, active subscriptions never received a Report Data message when the active preset changed - the new value was silently applied on the device side but never pushed to subscribers.

Problem

When a controller sends a SetActivePresetRequest command:

  1. The device correctly updates ActivePresetHandle internally ✅
  2. A direct read active-preset-handle returns the new value correctly ✅
  3. No subscription report is ever sent to notify subscribers ❌

This means any controller relying on subscriptions (the standard Matter
approach) will never learn about the change without explicitly polling the
attribute.

Confirmed against:

  • The Linux thermostat example (examples/thermostat/linux)
  • Eve Thermo hardware (third-party device)

Root Cause

In thermostat-server-presets.cpp, SetActivePreset() was missing a call to
MatterReportingAttributeChangeCallback() after a successful
SetActivePresetHandle():

// Before (missing reporting notification)
CHIP_ERROR err = delegate->SetActivePresetHandle(presetHandle);
if (err != CHIP_NO_ERROR) { ... }
return Status::Success;
// ← no MatterReportingAttributeChangeCallback call here

Related issues

Fixes: #43582

Testing

I am not a member of the CSA, so I do not have permission to update the Python test file. I don't know what step number to assign to a new test.
Tested with thermostat/linux example:
https://github.com/project-chip/connectedhomeip/tree/master/examples/thermostat/linux

[1773440571.128] [33635:33635] [DMG] Received command for Endpoint=1 Cluster=0x0000_0201 Command=0x0000_0006
[1773440571.128] [33635:33635] [-] Set ActivePresetHandle to
[1773440571.128] [33635:33635] [-] 0x01,
[1773440571.128] [33635:33635] [DMG] Endpoint 1, Cluster 0x0000_0201 update version to 3902755c
[1773440571.128] [33635:33635] [DMG] Cannot merge the new path into any existing path, create one.
[1773440571.128] [33635:33635] [DMG] Command handler moving to [NewRespons]
[1773440571.128] [33635:33635] [DMG] Command handler moving to [ Preparing]
[1773440571.128] [33635:33635] [DMG] Command handler moving to [AddingComm]
[1773440571.128] [33635:33635] [DMG] Command handler moving to [AddedComma]
[1773440571.129] [33635:33635] [DMG] Decreasing reference count for CommandHandlerImpl, remaining 1
[1773440571.129] [33635:33635] [DMG] Decreasing reference count for CommandHandlerImpl, remaining 0
[1773440571.129] [33635:33635] [DMG] Command handler moving to [AwaitingDe]
[1773440571.129] [33635:33635] [EM] <<< [E:1214r S:40911 M:111615808 (Ack:123586838)] (S) Msg TX from 000000000000005A to 1:000000000001B669 [269A] [UDP:[2a01:e0a:102b:8280:58a7:3cb5:d1bf:5241]:37418] --- Type 0001:09 (IM:InvokeCommandResponse) (B:68)
[1773440571.129] [33635:33635] [EM] ??1 [E:1214r S:40911 M:111615808] (S) Msg Retransmission to 1:000000000001B669 scheduled for 371ms from now [State:Active II:500 AI:300 AT:4000]
[1773440571.129] [33635:33635] [DMG] Command response sender moving to [AllInvokeR]
[1773440571.129] [33635:33635] [DMG] Building Reports for ReadHandler with LastReportGeneration = 0x00000017 DirtyGeneration = 0x00000018
[1773440571.129] [33635:33635] [DMG] <RE:Run> Cluster 201, Attribute 4e is dirty

Readability checklist

The checklist below will help the reviewer finish PR review in time and keep the
code readable:

  • PR title is
    descriptive
  • Apply the
    “When in Rome…”
    rule (coding style)
  • PR size is short
  • Try to avoid "squashing" and "force-update" in commit history
  • CI time didn't increase

See: Pull Request Guidelines

…anges

SetActivePreset() was calling delegate->SetActivePresetHandle() without
notifying the reporting engine, so active subscriptions never received
a Report Data message after a SetActivePresetRequest command. The new
value was silently applied on the device side (confirmed via a direct
read) but was invisible to subscribed controllers.

Add a call to MatterReportingAttributeChangeCallback() after a
successful SetActivePresetHandle() to mark the attribute dirty and
trigger a subscription report to all subscribers.
@CLAassistant
Copy link

CLAassistant commented Mar 13, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the app label Mar 13, 2026
Copy link
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 addresses a bug where changes to the ActivePresetHandle attribute in the Thermostat cluster were not being reported to subscribers. The fix correctly adds a call to MatterReportingAttributeChangeCallback after the attribute's value is updated via the delegate. This ensures that subscribers will receive notifications when the active preset changes. The change is correct and well-contained.

@lboue lboue marked this pull request as ready for review March 13, 2026 22:21
Copilot AI review requested due to automatic review settings March 13, 2026 22:21
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 PR ensures Thermostat preset updates trigger subscription reporting by explicitly marking the ActivePresetHandle attribute as changed when it’s updated via the server’s preset-handling path.

Changes:

  • Include the reporting API header needed to notify attribute changes.
  • Call MatterReportingAttributeChangeCallback() after successfully setting ActivePresetHandle so subscribers receive an updated report.

@github-actions
Copy link

github-actions bot commented Mar 13, 2026

PR #43583: Size comparison from 70b86c8 to 7c1d6d6

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 70b86c8 7c1d6d6 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1089396 1089396 0 0.0
RAM 144762 144762 0 0.0
bl616 lighting-app bl616+thread FLASH 1100324 1100324 0 0.0
RAM 104184 104184 0 0.0
bl616+wifi+shell FLASH 1586916 1586916 0 0.0
RAM 98080 98080 0 0.0
bl702 lighting-app bl702+eth FLASH 1052752 1052752 0 0.0
RAM 108357 108357 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 890764 890764 0 0.0
RAM 105748 105748 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 779164 779164 0 0.0
RAM 103324 103324 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 786528 786528 0 0.0
RAM 108508 108508 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 732724 732724 0 0.0
RAM 97316 97316 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 716160 716160 0 0.0
RAM 97476 97476 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 558106 558122 16 0.0
RAM 204504 204504 0 0.0
lock CC3235SF_LAUNCHXL FLASH 591230 591230 0 0.0
RAM 204744 204744 0 0.0
efr32 lock-app BRD4187C FLASH 971196 971196 0 0.0
RAM 125796 125796 0 0.0
BRD4338a FLASH 769268 769260 -8 -0.0
RAM 236544 236544 0 0.0
window-app BRD4187C FLASH 1074656 1074656 0 0.0
RAM 126440 126440 0 0.0
esp32 all-clusters-app c3devkit DRAM 98356 98356 0 0.0
FLASH 1596564 1596586 22 0.0
IRAM 93514 93514 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 857588 857604 16 0.0
RAM 161999 161999 0 0.0
nxp contact mcxw71+release FLASH 735808 735808 0 0.0
RAM 66936 66936 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1708508 1708524 16 0.0
RAM 213940 213940 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1607180 1607196 16 0.0
RAM 210812 210812 0 0.0
light cy8ckit_062s2_43012 FLASH 1470412 1470412 0 0.0
RAM 196988 196988 0 0.0
lock cy8ckit_062s2_43012 FLASH 1497092 1497092 0 0.0
RAM 224732 224732 0 0.0
qpg lighting-app qpg6200+debug FLASH 840636 840636 0 0.0
RAM 127780 127780 0 0.0
lock-app qpg6200+debug FLASH 779312 779312 0 0.0
RAM 118728 118728 0 0.0
realtek light-switch-app rtl8777g FLASH 720520 720520 0 0.0
RAM 113448 113448 0 0.0
lighting-app rtl8777g FLASH 767736 767736 0 0.0
RAM 114688 114688 0 0.0
stm32 light STM32WB5MM-DK FLASH 478820 478820 0 0.0
RAM 141324 141324 0 0.0
telink bridge-app tl7218x FLASH 728648 728648 0 0.0
RAM 95760 95760 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 852792 852792 0 0.0
RAM 44176 44176 0 0.0
tl7218x FLASH 844196 844196 0 0.0
RAM 99564 99564 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 725462 725462 0 0.0
RAM 55740 55740 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 788030 788030 0 0.0
RAM 74916 74916 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 725458 725458 0 0.0
RAM 33220 33220 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 616200 616200 0 0.0
RAM 118232 118232 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 842966 842970 4 0.0
RAM 97272 97272 0 0.0

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 54.12%. Comparing base (708056c) to head (d3f579d).

Files with missing lines Patch % Lines
...rs/thermostat-server/thermostat-server-presets.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43583      +/-   ##
==========================================
- Coverage   54.12%   54.12%   -0.01%     
==========================================
  Files        1550     1550              
  Lines      106947   106948       +1     
  Branches    13312    13312              
==========================================
  Hits        57888    57888              
- Misses      49059    49060       +1     

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

@lboue
Copy link
Contributor Author

lboue commented Mar 14, 2026

I created a task to add a Python test for the certification. This test must have been overlooked because the certification was approved even though some code was missing:

@github-actions
Copy link

github-actions bot commented Mar 15, 2026

PR #43583: Size comparison from 708056c to d3f579d

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 708056c d3f579d change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1090298 1090298 0 0.0
RAM 144778 144778 0 0.0
bl616 lighting-app bl616+thread FLASH 1100804 1100804 0 0.0
RAM 104216 104216 0 0.0
bl616+wifi+shell FLASH 1587676 1587676 0 0.0
RAM 98080 98080 0 0.0
bl702 lighting-app bl702+eth FLASH 1053234 1053234 0 0.0
RAM 108381 108381 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 891244 891244 0 0.0
RAM 105756 105756 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 780076 780076 0 0.0
RAM 103332 103332 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 787104 787104 0 0.0
RAM 108516 108516 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 733332 733332 0 0.0
RAM 97324 97324 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 716752 716752 0 0.0
RAM 97484 97484 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 558650 558666 16 0.0
RAM 204504 204504 0 0.0
lock CC3235SF_LAUNCHXL FLASH 591814 591814 0 0.0
RAM 204744 204744 0 0.0
efr32 lock-app BRD4187C FLASH 971764 971764 0 0.0
RAM 125828 125828 0 0.0
BRD4338a FLASH 769948 769948 0 0.0
RAM 236552 236552 0 0.0
window-app BRD4187C FLASH 1075368 1075360 -8 -0.0
RAM 126440 126440 0 0.0
esp32 all-clusters-app c3devkit DRAM 98372 98372 0 0.0
FLASH 1597182 1597204 22 0.0
IRAM 93514 93514 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 858144 858160 16 0.0
RAM 162019 162019 0 0.0
nxp contact mcxw71+release FLASH 736456 736456 0 0.0
RAM 66944 66944 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1709172 1709188 16 0.0
RAM 213948 213948 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1607868 1607884 16 0.0
RAM 210820 210820 0 0.0
light cy8ckit_062s2_43012 FLASH 1471620 1471620 0 0.0
RAM 196996 196996 0 0.0
lock cy8ckit_062s2_43012 FLASH 1497756 1497756 0 0.0
RAM 224740 224740 0 0.0
qpg lighting-app qpg6200+debug FLASH 841228 841228 0 0.0
RAM 127788 127788 0 0.0
lock-app qpg6200+debug FLASH 779920 779920 0 0.0
RAM 118736 118736 0 0.0
realtek light-switch-app rtl8777g FLASH 721176 721176 0 0.0
RAM 113456 113456 0 0.0
lighting-app rtl8777g FLASH 768912 768912 0 0.0
RAM 114696 114696 0 0.0
stm32 light STM32WB5MM-DK FLASH 479728 479728 0 0.0
RAM 141324 141324 0 0.0
telink bridge-app tl7218x FLASH 729310 729310 0 0.0
RAM 95772 95772 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 853790 853790 0 0.0
RAM 44188 44188 0 0.0
tl7218x FLASH 845200 845200 0 0.0
RAM 99576 99576 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 726122 726122 0 0.0
RAM 55752 55752 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 788690 788690 0 0.0
RAM 74928 74928 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 726116 726116 0 0.0
RAM 33232 33232 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 617198 617198 0 0.0
RAM 118244 118244 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 843970 843974 4 0.0
RAM 97284 97284 0 0.0

@lboue
Copy link
Contributor Author

lboue commented Mar 15, 2026

The Darwin test fails due to a memory leak (#43594). That has nothing to do with this request.

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.

[BUG] SetActivePreset does not trigger a subscription report for ActivePresetHandle attribute

3 participants