Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serverNode.state.commissioning.fabrics returns empty array on the first restart after commissioning is done #1639

Closed
Luligu opened this issue Jan 19, 2025 · 1 comment · Fixed by #1651

Comments

@Luligu
Copy link
Contributor

Luligu commented Jan 19, 2025

Hi,
serverNode.state.commissioning.fabrics returns an empty array on the first restart after the device has been commissioned.

After this first restart, all the other time the array contains the fabrics.

To reproduce:

  • reset the storage;
  • pair a device;
  • restart and call serverNode.state.commissioning.fabrics from serverNode.lifecycle.online.on.

Thanks.


/** This event is triggered when the device went online. This means that it is discoverable in the network. */
serverNode.lifecycle.online.on(() => {
  this.log.notice(`Server node for ${storeId} is online`);
  if (!serverNode.lifecycle.isCommissioned) {
    this.log.notice(`Server node for ${storeId} is not commissioned. Pair to commission ...`);
    const { qrPairingCode, manualPairingCode } = serverNode.state.commissioning.pairingCodes;
    if (this.bridgeMode === 'bridge') {
      this.matterbridgeQrPairingCode = qrPairingCode;
      this.matterbridgeManualPairingCode = manualPairingCode;
      this.matterbridgeFabricInformations = [];
      this.matterbridgeSessionInformations = [];
      this.matterbridgePaired = false;
      this.log.notice(`QR Code URL: https://project-chip.github.io/connectedhomeip/qrcode.html?data=${qrPairingCode}`);
      this.log.notice(`Manual pairing code: ${manualPairingCode}`);
    }
    if (this.bridgeMode === 'childbridge') {
      const plugin = this.plugins.get(storeId);
      if (plugin) {
        plugin.qrPairingCode = qrPairingCode;
        plugin.manualPairingCode = manualPairingCode;
        plugin.fabricInformations = [];
        plugin.sessionInformations = [];
        plugin.paired = false;
        this.log.notice(`QR Code URL: https://project-chip.github.io/connectedhomeip/qrcode.html?data=${qrPairingCode}`);
        this.log.notice(`Manual pairing code: ${manualPairingCode}`);
      }
    }
  } else {
    this.log.notice(`Server node for ${storeId} is already commissioned. Waiting for controllers to connect ...`);
    sanitizeFabrics(serverNode.state.commissioning.fabrics, true);
  }
  this.frontend.wssSendRefreshRequired();
});

@Apollon77 Apollon77 added the bug Something isn't working label Jan 20, 2025
@Apollon77
Copy link
Collaborator

As discussed in Discord please add debug logs from these calls.

I expect some case of async things because the content of the fabrics array is always build dynamically using the same event "lifecycle.online", So I would assume that it depends on which event is registered first.
A Log should at least show when fabrics get initialized.

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 a pull request may close this issue.

2 participants