Skip to content

Conversation

@SuGlider
Copy link
Collaborator

Description of Change

This PR adds HoldTime and HoldTimeLimits attributes to Arduino Matter Occupancy Sensor endpoint.
It also adds a user callback for the device get notified that the Matter Controller has changed such parameter.

It is possible for the device to change both HoldTime and HoldTimeLimits using the Arduino Matter API.

Test Scenarios

Tested using Home Assistant with WiFi using the ESP32-C6.
The test uses the provided exmaple.

Related links

Closes #12135

@SuGlider SuGlider added this to the 3.3.0 milestone Dec 17, 2025
@SuGlider SuGlider self-assigned this Dec 17, 2025
@SuGlider SuGlider added the Area: Matter Issues and Feature Request about Matter Protocol label Dec 17, 2025
@SuGlider SuGlider moved this from Todo to In Progress in Arduino ESP32 Core Project Roadmap Dec 17, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

Messages
📖 This PR seems to be quite large (total lines of code: 1080), you might consider splitting it into smaller PRs

👋 Hello SuGlider, 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.
- Addressing info messages (📖) is strongly recommended; they're less critical but valuable.
- 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 2efca1d

@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

Test Results

 90 files   90 suites   29m 48s ⏱️
 66 tests  56 ✅ 0 💤 10 ❌
675 runs  655 ✅ 0 💤 20 ❌

For more details on these failures, see this check.

Results for commit 78d3f49.

♻️ This comment has been updated with latest results.

@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
ESP32C50‼️ +2K0.00⚠️ +0.100⚠️ +1920.00⚠️ +0.17
ESP32S3000.000.00000.000.00
ESP32S20⚠️ +18400.00⚠️ +0.110⚠️ +2000.00⚠️ +0.22
ESP32C30‼️ +2K0.00⚠️ +0.130⚠️ +1920.00⚠️ +0.20
ESP32C6000.000.00000.000.00
ESP32H20‼️ +2K0.00⚠️ +0.110⚠️ +1760.00⚠️ +0.16
ESP320⚠️ +18920.00⚠️ +0.110⚠️ +3200.00⚠️ +0.30
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32C5ESP32S3ESP32S2ESP32C3ESP32C6ESP32H2ESP32
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
libraries/Matter/examples/MatterColorLight⚠️ +1996⚠️ +152--⚠️ +1628⚠️ +176⚠️ +2000⚠️ +152--⚠️ +2004⚠️ +152⚠️ +1660⚠️ +304
libraries/Matter/examples/MatterCommissionTest⚠️ +2008⚠️ +152--⚠️ +1580⚠️ +176⚠️ +2004⚠️ +152--⚠️ +2000⚠️ +152⚠️ +1628⚠️ +296
libraries/Matter/examples/MatterComposedLights⚠️ +1988⚠️ +160--⚠️ +1540⚠️ +176⚠️ +2002⚠️ +160--⚠️ +2016⚠️ +160⚠️ +1696⚠️ +296
libraries/Matter/examples/MatterContactSensor⚠️ +2002⚠️ +152--⚠️ +1580⚠️ +176⚠️ +2016⚠️ +152--⚠️ +2006⚠️ +152⚠️ +1516⚠️ +296
libraries/Matter/examples/MatterDimmableLight⚠️ +2002⚠️ +152--⚠️ +1592⚠️ +176⚠️ +2002⚠️ +152--⚠️ +1992⚠️ +152⚠️ +1680⚠️ +304
libraries/Matter/examples/MatterDimmablePlugin⚠️ +2002⚠️ +152--⚠️ +1596⚠️ +176⚠️ +2002⚠️ +152--⚠️ +1990⚠️ +152⚠️ +1684⚠️ +304
libraries/Matter/examples/MatterEnhancedColorLight⚠️ +1978⚠️ +152--⚠️ +1516⚠️ +176⚠️ +2004⚠️ +152--⚠️ +1972⚠️ +152⚠️ +1704⚠️ +304
libraries/Matter/examples/MatterEvents⚠️ +2008⚠️ +152--⚠️ +1632⚠️ +176⚠️ +2006⚠️ +152--⚠️ +2000⚠️ +152⚠️ +1644⚠️ +296
libraries/Matter/examples/MatterFan⚠️ +1996⚠️ +160--⚠️ +1584⚠️ +176⚠️ +2006⚠️ +152--⚠️ +1982⚠️ +176⚠️ +1652⚠️ +304
libraries/Matter/examples/MatterHumiditySensor⚠️ +1992⚠️ +160--⚠️ +1580⚠️ +176⚠️ +2026⚠️ +160--⚠️ +2012⚠️ +160⚠️ +1504⚠️ +296
libraries/Matter/examples/MatterLambdaSingleCallbackManyEPs⚠️ +2002⚠️ +160--⚠️ +1604⚠️ +168⚠️ +2014⚠️ +160--⚠️ +2006⚠️ +160⚠️ +1648⚠️ +296
libraries/Matter/examples/MatterMinimum⚠️ +2010⚠️ +152--⚠️ +1588⚠️ +176⚠️ +2006⚠️ +152--⚠️ +1994⚠️ +152⚠️ +1644⚠️ +296
libraries/Matter/examples/MatterOccupancySensor‼️ +2K⚠️ +192--⚠️ +1840⚠️ +200‼️ +2K⚠️ +192--‼️ +2K⚠️ +176⚠️ +1892⚠️ +320
libraries/Matter/examples/MatterOccupancyWithHoldTime--------------
libraries/Matter/examples/MatterOnIdentify⚠️ +2012⚠️ +152--⚠️ +1612⚠️ +176⚠️ +2010⚠️ +152--⚠️ +2000⚠️ +152⚠️ +1644⚠️ +296
libraries/Matter/examples/MatterOnOffLight⚠️ +2018⚠️ +152--⚠️ +1596⚠️ +176⚠️ +2010⚠️ +152--⚠️ +2004⚠️ +152⚠️ +1700⚠️ +296
libraries/Matter/examples/MatterOnOffPlugin⚠️ +2012⚠️ +152--⚠️ +1596⚠️ +176⚠️ +2006⚠️ +152--⚠️ +1998⚠️ +152⚠️ +1636⚠️ +296
libraries/Matter/examples/MatterPressureSensor⚠️ +1992⚠️ +160--⚠️ +1572⚠️ +176⚠️ +2026⚠️ +160--⚠️ +2012⚠️ +160⚠️ +1508⚠️ +296
libraries/Matter/examples/MatterRainSensor⚠️ +2004⚠️ +152--⚠️ +1580⚠️ +176⚠️ +2016⚠️ +152--⚠️ +2008⚠️ +152⚠️ +1500⚠️ +296
libraries/Matter/examples/MatterSimpleBlinds⚠️ +2006⚠️ +152--⚠️ +1640⚠️ +176⚠️ +2002⚠️ +152--⚠️ +1994⚠️ +152⚠️ +1664⚠️ +296
libraries/Matter/examples/MatterSmartButton⚠️ +2018⚠️ +160--⚠️ +1592⚠️ +176⚠️ +2010⚠️ +160--⚠️ +2018⚠️ +160⚠️ +1664⚠️ +296
libraries/Matter/examples/MatterStatus⚠️ +2014⚠️ +152--⚠️ +1580⚠️ +176⚠️ +2018⚠️ +152--⚠️ +2004⚠️ +152⚠️ +1628⚠️ +296
libraries/Matter/examples/MatterTemperatureControlledCabinet⚠️ +1994⚠️ +160--⚠️ +1588⚠️ +176⚠️ +2012⚠️ +160--⚠️ +2016⚠️ +160⚠️ +1568⚠️ +296
libraries/Matter/examples/MatterTemperatureControlledCabinetLevels⚠️ +1994⚠️ +160--⚠️ +1544⚠️ +176⚠️ +2010⚠️ +160--⚠️ +2016⚠️ +160⚠️ +1564⚠️ +296
libraries/Matter/examples/MatterTemperatureLight⚠️ +1976⚠️ +152--⚠️ +1512⚠️ +176⚠️ +1998⚠️ +152--⚠️ +1974⚠️ +152⚠️ +1596⚠️ +304
libraries/Matter/examples/MatterTemperatureSensor⚠️ +1992⚠️ +160--⚠️ +1576⚠️ +176⚠️ +2028⚠️ +160--⚠️ +2012⚠️ +160⚠️ +1520⚠️ +296
libraries/Matter/examples/MatterThermostat⚠️ +2024⚠️ +160--⚠️ +1616⚠️ +176⚠️ +2014⚠️ +160--⚠️ +2000⚠️ +160⚠️ +1636⚠️ +296
libraries/Matter/examples/MatterWaterFreezeDetector⚠️ +2004⚠️ +152--⚠️ +1580⚠️ +176⚠️ +2016⚠️ +152--⚠️ +2008⚠️ +152⚠️ +1512⚠️ +296
libraries/Matter/examples/MatterWaterLeakDetector⚠️ +2004⚠️ +152--⚠️ +1580⚠️ +176⚠️ +2016⚠️ +152--⚠️ +2008⚠️ +152⚠️ +1496⚠️ +296
libraries/Matter/examples/MatterWindowCovering⚠️ +2026⚠️ +152--⚠️ +1612⚠️ +176⚠️ +2018⚠️ +152--⚠️ +2010⚠️ +152⚠️ +1720⚠️ +304

@lboue
Copy link
Contributor

lboue commented Dec 17, 2025

My test with HA worked too.

@P-R-O-C-H-Y P-R-O-C-H-Y added the Status: Review needed Issue or PR is awaiting review label Dec 17, 2025
Copy link
Member

@pedrominatel pedrominatel left a comment

Choose a reason for hiding this comment

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

Nice work @SuGlider. I wish all the README's be like this!

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 adds HoldTime and HoldTimeLimits attributes to the Matter Occupancy Sensor endpoint, allowing control over how long the sensor maintains an "occupied" state after detection. The implementation includes a callback mechanism for Matter Controller updates and demonstrates HoldTime expiration logic in a comprehensive example.

Key changes:

  • Added HoldTime attribute support with getter/setter methods and validation against configurable limits
  • Implemented custom AttributeAccessInterface wrapper to intercept HoldTime writes and trigger user callbacks
  • Added complete example demonstrating HoldTime functionality with persistence across reboots using Preferences

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.h Adds HoldTime/HoldTimeLimits API methods, callback typedef, private member variables, and friend class declaration
libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.cpp Implements HoldTime functionality with attribute creation, validation, event loop scheduling, and custom AttributeAccessInterface wrapper
libraries/Matter/keywords.txt Adds keywords for new types and methods (OccupancySensorType_t, HoldTimeChangeCB, setHoldTime, getHoldTime, setHoldTimeLimits, onHoldTimeChange, sensor type literals)
libraries/Matter/examples/MatterOccupancyWithHoldTime/ci.yml Configures CI with huge_app partition scheme and Matter data model requirement
libraries/Matter/examples/MatterOccupancyWithHoldTime/README.md Comprehensive documentation covering features, setup, HoldTime behavior, PIR sensor integration, and troubleshooting
libraries/Matter/examples/MatterOccupancyWithHoldTime/MatterOccupancyWithHoldTime.ino Complete example with simulated occupancy sensor, HoldTime persistence, callback handling, and commissioning flow
docs/en/matter/ep_occupancy_sensor.rst Documents new HoldTime API methods with examples and usage guidance

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

Area: Matter Issues and Feature Request about Matter Protocol Status: Review needed Issue or PR is awaiting review

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

[Request] Matter HoldTime attribute for MatterOccupancySensor

6 participants