Skip to content

Upgrade Matter.js to 0.16#2429

Closed
Pierre-Gilles wants to merge 13 commits intomasterfrom
updgrade-matter-0-16-8
Closed

Upgrade Matter.js to 0.16#2429
Pierre-Gilles wants to merge 13 commits intomasterfrom
updgrade-matter-0-16-8

Conversation

@Pierre-Gilles
Copy link
Copy Markdown
Contributor

@Pierre-Gilles Pierre-Gilles commented Feb 9, 2026

Pull Request check-list

To ensure your Pull Request can be accepted as fast as possible, make sure to review and check all of these items:

  • If your changes affect the code, did you write the tests?
  • Are tests passing? (npm test on both front/server)
  • Is the linter passing? (npm run eslint on both front/server)
  • Did you run prettier? (npm run prettier on both front/server)
  • If you are adding a new feature/service, did you run the integration comparator? (npm run compare-translations on front)
  • Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community (forum) for testing before merging.
  • If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
  • If you are adding a new features/services which needs explanation, did you modify the user documentation? See the GitHub repo and the website.
  • Did you add fake requests data for the demo mode (front/src/config/demo.js) so that the demo website is working without a backend? (if needed) See https://demo.gladysassistant.com.

NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.

Description of change

Please provide a description of the change here. It's always best with screenshots, so don't hesitate to add some!

Summary by CodeRabbit

  • Chores

    • Updated Matter-related dependencies to v0.16.10 for improved compatibility and stability.
  • Refactor

    • Internal device handling now consistently uses accessor-based APIs and enforces stricter device-data validation.
  • Bug Fixes / Improvements

    • More robust state reporting and unit conversions across sensors and actuators; added color state emission and safer attribute reads.
  • Tests

    • Test suites updated to match the new accessor-based device interfaces.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Feb 9, 2026

Deploying gladys-plus with  Cloudflare Pages  Cloudflare Pages

Latest commit: 97df3e6
Status: ✅  Deploy successful!
Preview URL: https://585e119e.gladys-plus.pages.dev
Branch Preview URL: https://updgrade-matter-0-16-8.gladys-plus.pages.dev

View logs

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 9, 2026

Codecov Report

❌ Patch coverage is 99.35484% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.81%. Comparing base (25cbcdd) to head (97df3e6).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
server/services/matter/lib/matter.handleNode.js 98.00% 1 Missing ⚠️
server/services/matter/lib/matter.init.js 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2429      +/-   ##
==========================================
- Coverage   98.81%   98.81%   -0.01%     
==========================================
  Files        1007     1007              
  Lines       17534    17674     +140     
==========================================
+ Hits        17326    17464     +138     
- Misses        208      210       +2     

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

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Feb 9, 2026

#4040 Bundle Size — 11.41MiB (0%).

97df3e6(current) vs 25cbcdd master#4039(baseline)

Warning

Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  no changes
                 Current
#4040
     Baseline
#4039
No change  Initial JS 6.4MiB 6.4MiB
No change  Initial CSS 310.49KiB 310.49KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 51 51
No change  Assets 179 179
No change  Modules 1643 1643
No change  Duplicate Modules 21 21
No change  Duplicate Code 0.94% 0.94%
No change  Packages 136 136
No change  Duplicate Packages 2 2
Bundle size by type  no changes
                 Current
#4040
     Baseline
#4039
No change  JS 8.3MiB 8.3MiB
No change  IMG 2.66MiB 2.66MiB
No change  CSS 328.34KiB 328.34KiB
No change  Fonts 93.55KiB 93.55KiB
No change  Other 18.82KiB 18.82KiB
No change  HTML 13.58KiB 13.58KiB

Bundle analysis reportBranch updgrade-matter-0-16-8Project dashboard


Generated by RelativeCIDocumentationReport issue

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 20, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR bumps Matter package versions and replaces direct device property access (clusterClients, childEndpoints) with accessor methods (getClusterClientById, getAllClusterClients, getChildEndpoints) across the Matter service and tests. getNodes now requires deviceData.basicInformation.

Changes

Cohort / File(s) Summary
Dependency Updates
server/package.json, server/services/matter/package.json
Bumped @matter/main and @project-chip/matter.js from ^0.13.0^0.16.10.
Core Matter Implementation
server/services/matter/lib/matter.getNodes.js, server/services/matter/lib/matter.handleNode.js, server/services/matter/lib/matter.listenToStateChange.js, server/services/matter/lib/matter.setValue.js, server/services/matter/utils/convertToGladysDevice.js
Replaced direct property access (device.clusterClients, device.childEndpoints) with accessor calls (getAllClusterClients(), getChildEndpoints(), getClusterClientById(id)). Added stricter getNodes validation for deviceData.basicInformation and an internal color-state helper in listenToStateChange. Wrapped bridged attribute reads with try/catch and updated iteration guards.
Tests (Matter service)
server/test/services/matter/lib/... (listenToStateChange.test.js, matter.getNodes.test.js, matter.init.test.js, matter.pairDevice.test.js, matter.refreshDevices.test.js, matter.setValue.test.js)
Updated test fixtures/mocks to expose cluster clients and endpoints via getClusterClientById, getAllClusterClients, and getChildEndpoints instead of direct clusterClients/childEndpoints properties; test behavior preserved.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped from maps to methods bright,
Cluster clients now fetched just right,
Versions climbed and tests stayed true,
Endpoints called — a cleaner view,
My whiskers twitch, the code feels light.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Upgrade Matter.js to 0.16' directly and clearly describes the main change: upgrading the Matter.js library from 0.13.x to 0.16.10 across package.json files and corresponding code updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch updgrade-matter-0-16-8
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Pierre-Gilles
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 20, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server/services/matter/lib/matter.setValue.js (1)

29-35: ⚠️ Potential issue | 🔴 Critical

Child endpoint traversal incompatible with Matter.js 0.16.8 API.

The childEndpoints property does not exist in the new Matter.js 0.16.8 endpoint API. In the current architecture, child endpoints should be accessed via endpoint.parts (using parts.get(id) for lookup or hasParts to check existence), not through a childEndpoints property or getChildEndpoints() method.

The recursion at lines 29–35 requires migration to the new Parts API:

  • Replace parentDevice.childEndpoints with parentDevice.parts
  • Use parts.get(deviceNumber) or iterate via parts directly
  • Consider whether endpoint.visit() can replace the recursive traversal entirely

This is more than a compatibility layer—it requires refactoring the traversal logic to align with the new endpoint composition model.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/services/matter/lib/matter.setValue.js` around lines 29 - 35, The
traversal uses the removed parentDevice.childEndpoints API; update
findDeviceRecursively to use the new Parts API: check parentDevice.parts (or
parentDevice.hasParts()) instead of childEndpoints, locate a child via
parentDevice.parts.get(deviceNumber) or iterate parentDevice.parts to find
matching part, and recurse with that part and remainingPath; alternatively
refactor to use endpoint.visit() to traverse parts if that simplifies the
recursion. Ensure all references to childEndpoints/getChildEndpoints() are
replaced and adjust any existence checks to use hasParts()/parts accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@server/package.json`:
- Line 49: Update the dependency entry for `@matter/main` in package.json to
reference the newer 0.16.9 release (e.g., change the version string from
"^0.16.8" to "^0.16.9" or ensure the caret range allows the latest 0.16.9) so
the project pulls the latest patch; locate the "@matter/main" line in
package.json and modify the version accordingly, then run your package manager
install to verify compatibility.

---

Outside diff comments:
In `@server/services/matter/lib/matter.setValue.js`:
- Around line 29-35: The traversal uses the removed parentDevice.childEndpoints
API; update findDeviceRecursively to use the new Parts API: check
parentDevice.parts (or parentDevice.hasParts()) instead of childEndpoints,
locate a child via parentDevice.parts.get(deviceNumber) or iterate
parentDevice.parts to find matching part, and recurse with that part and
remainingPath; alternatively refactor to use endpoint.visit() to traverse parts
if that simplifies the recursion. Ensure all references to
childEndpoints/getChildEndpoints() are replaced and adjust any existence checks
to use hasParts()/parts accordingly.

Comment thread server/package.json Outdated
@Pierre-Gilles Pierre-Gilles changed the title Upgrade Matter.js to 0.16.8 Upgrade Matter.js to 0.16 Mar 6, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server/services/matter/lib/matter.handleNode.js (1)

134-137: ⚠️ Potential issue | 🟠 Major

Guard deviceData.basicInformation before calling handleDevice.

We only bail out when nodeDetail.deviceData is missing, but Line 146 still passes nodeDetail.deviceData.basicInformation and handleDevice dereferences it immediately on Line 20. A partially populated node payload will still throw before the new bridged-attribute fallbacks even run.

Proposed fix
 async function handleNode(nodeDetail) {
   logger.debug(`Matter: Handling node ${nodeDetail.nodeId}`);
-  if (!nodeDetail.deviceData) {
-    logger.warn(`Matter: Node ${nodeDetail.nodeId} has no device data`);
+  if (!nodeDetail.deviceData?.basicInformation) {
+    logger.warn(`Matter: Node ${nodeDetail.nodeId} has no device basic information`);
     return;
   }
+  const basicInformation = nodeDetail.deviceData.basicInformation;
   const node = await this.commissioningController.getNode(nodeDetail.nodeId);
   this.nodesMap.set(nodeDetail.nodeId, node);
   const devices = node.getDevices();
   const boundListenToStateChange = this.listenToStateChange.bind(this);
   await Promise.each(devices, async (device) => {
@@
     await handleDevice(
       nodeDetail.nodeId,
-      nodeDetail.deviceData.basicInformation,
+      basicInformation,
       node,
       device,
       this.devices,

Also applies to: 144-146

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/services/matter/lib/matter.handleNode.js` around lines 134 - 137, The
code currently only checks nodeDetail.deviceData and then calls handleDevice
with nodeDetail.deviceData.basicInformation, which can be undefined and cause a
crash; update the guard to ensure deviceData.basicInformation exists (or provide
a safe default) before calling handleDevice (references: nodeDetail,
deviceData.basicInformation, handleDevice) — either return/log when
basicInformation is missing or pass a validated/default object so handleDevice
and its immediate dereferences are safe.
🧹 Nitpick comments (1)
server/services/matter/lib/matter.handleNode.js (1)

40-40: Include the failing endpoint in these warnings.

nodeId is shared by every bridged child on the node, so these messages still won't tell you which endpoint failed when several children are involved. Adding device.number here, or computing newDevicePath before the reads, would make the warnings actionable.

Also applies to: 49-49, 58-58, 67-67, 76-76, 85-85

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/services/matter/lib/matter.handleNode.js` at line 40, The warning
messages using logger.warn currently only include nodeId so they are ambiguous
for bridged children; update each warn at the spots referencing nodeId (the
calls around reading bridged vendorName, productName, deviceType, deviceName,
and vendorId) to also include the failing endpoint by computing newDevicePath
(or reading device.number) before the reads and interpolating either
newDevicePath or device.number into the log message (i.e., change the
logger.warn calls that mention nodeId and e.message to include device.number or
newDevicePath alongside nodeId so the warnings uniquely identify which bridged
child failed).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@server/services/matter/lib/matter.handleNode.js`:
- Around line 134-137: The code currently only checks nodeDetail.deviceData and
then calls handleDevice with nodeDetail.deviceData.basicInformation, which can
be undefined and cause a crash; update the guard to ensure
deviceData.basicInformation exists (or provide a safe default) before calling
handleDevice (references: nodeDetail, deviceData.basicInformation, handleDevice)
— either return/log when basicInformation is missing or pass a validated/default
object so handleDevice and its immediate dereferences are safe.

---

Nitpick comments:
In `@server/services/matter/lib/matter.handleNode.js`:
- Line 40: The warning messages using logger.warn currently only include nodeId
so they are ambiguous for bridged children; update each warn at the spots
referencing nodeId (the calls around reading bridged vendorName, productName,
deviceType, deviceName, and vendorId) to also include the failing endpoint by
computing newDevicePath (or reading device.number) before the reads and
interpolating either newDevicePath or device.number into the log message (i.e.,
change the logger.warn calls that mention nodeId and e.message to include
device.number or newDevicePath alongside nodeId so the warnings uniquely
identify which bridged child failed).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3ac2f814-3ff5-455b-8548-fc7adecc159d

📥 Commits

Reviewing files that changed from the base of the PR and between 9653399 and 3320d59.

📒 Files selected for processing (1)
  • server/services/matter/lib/matter.handleNode.js

@Pierre-Gilles
Copy link
Copy Markdown
Contributor Author

Close in favor of #2501

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant