google-home / sample-apps-for-matter-android

The Google Home Sample App for Matter (GHSA for Matter) uses the Home Mobile SDK to create an Android app that's similar to Google Home.
Apache License 2.0
108 stars 38 forks source link

Aggregator Device not showing properly and Device Type is showing as TYPE_UNKNOWN #220

Open mahadev-0007 opened 3 weeks ago

mahadev-0007 commented 3 weeks ago

I made a aggregrator endpoint device (Bridge Node) with matter.js and the device connects but device type is not recognised and functions are not showing properly

But I made an onOff light and it works perfectly

Aggregrator Code ------

const server = await ServerNode.create({
    // Required: Give the Node a unique ID which is used to store the state of this node
    id: uniqueId,

    // Provide Network relevant configuration like the port
    // Optional when operating only one device on a host, Default port is 5540
    network: {
      port: port,
    },

    // Provide Commissioning relevant settings
    // Optional for development/testing purposes
    commissioning: {
      passcode: passcode,
      discriminator: discriminator,
    },

    // Provide Node announcement settings
    // Optional: If Ommitted some development defaults are used
    productDescription: {
      name: productName,
      deviceType: AggregatorEndpoint.deviceType,
    },

    // Provide defaults for the BasicInformation cluster on the Root endpoint
    // Optional: If Omitted some development defaults are used
    basicInformation: {
      vendorName,
      vendorId: VendorId(vendorId),
      nodeLabel: productName,
      productName,
      productLabel: productName,
      productId,
      serialNumber: `matterjs-${uniqueId}`,
      uniqueId,
    },
  });

  const aggregator = new Endpoint(AggregatorEndpoint, { id: "aggregator" });

  await server.add(aggregator);

  const name = `OnOff Socket 1`;

  const endpoint = new Endpoint(
    OnOffPlugInUnitDevice.with(BridgedDeviceBasicInformationServer),
    {
      id: `onoff-socket-1`,
      bridgedDeviceBasicInformation: {
        nodeLabel: name,
        productName: name,
        productLabel: name,
        serialNumber: `node-matter-5678-3`,
        reachable: true,
      },
    }
  );
  await aggregator.add(endpoint);

  endpoint.events.identify.startIdentifying.on(() => {
    console.log(
      `Run identify logic for ${name}, ideally blink a light every 0.5s ...`
    );
  });

  endpoint.events.identify.stopIdentifying.on(() => {
    console.log(`Stop identify logic for ${name} ...`);
  });

  endpoint.events.onOff.onOff$Changed.on((value) => {
    executeCommand(value ? `on${i}` : `off${i}`);
    console.log(`${name} is now ${value ? "ON" : "OFF"}`);
  });

  await server.start();

Is there any problem with the device type I am mentioning or this app havent implemented bridge yet?