FezVrasta / node-red-matter

Create Virtual Devices with Ease for the Matter Protocol!
38 stars 7 forks source link

Can't connect to device from Alexa #12

Closed Nik19792000 closed 6 months ago

Nik19792000 commented 6 months ago

Hi, I've been able to connect to Matter devices (in node-red-matter) from Google Home, but it doesn't work with Alexa (Echo Dot). Alexa first says "Looking for device" and then "Connecting to your device" and then "Something went wrong". On the other hand it doesn't show "Connecting to your device" if I give an invalid pairing code. Debug logs in Node-red look like this: 2024-01-02 15:51:48.609 DEBUG MdnsScanner Found commissionable device 346C995C72FB2B84._matterc._udp.local with discriminator 3858/15 ... 2024-01-02 15:51:48.690 DEBUG MdnsScanner Found commissionable device 5B80FA48C1029259._matterc._udp.local with discriminator 2214/8 ... 2024-01-02 15:54:36.449 DEBUG MdnsScanner Found commissionable device 346C995C72FB2B84._matterc._udp.local with discriminator 3858/15 ... 2024-01-02 15:54:36.482 DEBUG MdnsScanner Found commissionable device 5B80FA48C1029259._matterc._udp.local with discriminator 2214/8 ...

I tried to connect to either of the two devices unsuccessfully. Any idea what could be the issue?

Apollon77 commented 6 months ago

For Alexa it is very important to use the very first device/bridge added to the Matter node because only this gets port 5540 and Alexa only searches for Port 5540. Means: Alexa only finds ONE device or bridge per Host!

FezVrasta commented 6 months ago

Documented here https://github.com/FezVrasta/node-red-matter/wiki/Documentation#alexa-wont-pair

Nik19792000 commented 6 months ago

Hi @FezVrasta, thanks that helps, but I'd like to clarify the port assignment. Based on this code, ports of devices are randomly assigned during every start: https://github.com/FezVrasta/node-red-matter/blob/69851136c202d87f6b848482195221617eae22d7/src/modules/matter-device.ts#L85

Accordingly also the first device will hardly ever get port 5540. I've hard-coded port 5540 in the code and Alexa is indeed able to connect to the device. It might be good to either assign a port in the device node or somewhere define a default device, which will always get port 5540.

If I understand it right, then Alexa will only be able to ever connect to a single node-red-matter device unless I do some funny mapping where I assign virtual IPs and map the ports for each device.

FezVrasta commented 6 months ago

We could add a configuration option to specify the port probably. At a controller node level.

Nik19792000 commented 6 months ago

I just noticed that the device node already has a field to define the port :) Am I right that Alexa will only be able to use one node-red-matter device? Matter.js says "composed devices not yet supported" by Alexa.

FezVrasta commented 6 months ago

composed devices are devices that group under a single entity more controls (for example a fan with a built-in light)

Nik19792000 commented 6 months ago

yes, I would have tried to abuse that to group multiple devices under one composed device. As this doesn't work and Alexa only considers one port, we would be limited to a single node-red-matter device, right?

FezVrasta commented 6 months ago

You can attach as many devices as you like to a single controller, and then pair the controller to Alexa.

Nik19792000 commented 6 months ago

Even after reading some of the Matter specification and half of your code, I still have a couple of questions:

  1. Alexa (e.g. Echo Dot), Google Home (e.g. Nest Mini) and Home Assistant can act as Matter Controller. Are you suggesting to attach devices created in node-red-matter to Google Home first and then pair it with Alexa? That doesn't seem to be possible. Are you referring to a Matter Bridge rather than a Matter Controller?
  2. When I try to configure a Matter Controller in Node-Red, it asks for Pairing Code, IP and Port. While I can find out IP and maybe even port, none of the above mentioned Controllers provide a Pairing Code that I could use to connect it to node-red-matter. How is this supposed to work?
FezVrasta commented 6 months ago

I meant bridge, sorry

Nik19792000 commented 6 months ago

Can you also answer the second question? Is the Controller Status node rather a Bridge Status node or where can I get the pairing code for a Controller?

FezVrasta commented 6 months ago

You need to create a matter-server configuration node, then attach to it a matter-aggregator, and then on each device you want to pair to Alexa you need to assign the aggregator node, you do that by selecting "Aggregated" in the "Device Category" option.

CleanShot 2024-01-05 at 1  53 34@2x