[MAJOR UPDATE] @sammachin/node-red-matter-bridge

OK
Well, what I do, is scan the NodeRED bridge QR code,
I then get offered to connect to SmartTHings but since that is some sort of Samsung propriety thingy I select use "add to different app"
It then comes up and suggests Google Home (but says it's not installed) but I don't have any Google home so I select "Choose other app"

Get offered a list of apps and I choose Amazon Alexa
It then scans for devices but doesn't find any

What is supposed to happen?

So the way I always do it is to scan the code from within the Alexa app.

In Alexa go to devices, then click + then there should me a matter logo, click that and then it will let you scan the code.

If I go down that route, it sits there saying Still looking for your device - try bringing it closer to your echo and your phone :frowning:

It then fails and wants me to put my device in pairing mode.

Do I need to get a real matter device before I can use this bridge for virtual matter devices?

I wondering if I'm lacking a fundemental grasp of what this bridge is for :frowning:

@sammachin I thought I would give this a try with my Alexa setup, to see if it worked for me but it seems to be crashing NR ?

Started Node-RED graphical event wiring tool.
23 Nov 16:38:28 - [info]
Welcome to Node-RED
===================
23 Nov 16:38:28 - [info] Node-RED version: v4.0.4
23 Nov 16:38:28 - [info] Node.js  version: v20.18.0
23 Nov 16:38:28 - [info] Linux 6.1.21-v8+ arm64 LE
23 Nov 16:38:28 - [info] Loading palette nodes
23 Nov 16:38:43 - [info] Worldmap version 5.0.4
23 Nov 16:38:43 - [info] Dashboard version 3.6.5 started at /ui
23 Nov 16:38:45 - [info] Settings file  : /home/pi/.node-red/settings.js
23 Nov 16:38:45 - [info] HTTP Static    : /home/pi/.node-red/public > /
23 Nov 16:38:45 - [info] Context store  : 'default' [module=localfilesystem]
23 Nov 16:38:45 - [info] Context store  : 'memoryOnly' [module=memory]
23 Nov 16:38:45 - [info] User directory : /home/pi/.node-red
23 Nov 16:38:45 - [warn] Projects disabled : editorTheme.projects.enabled=false
23 Nov 16:38:45 - [warn] Flows file name not set. Generating name using hostname.
23 Nov 16:38:45 - [info] Flows file     : /home/pi/.node-red/flows_pi-server.home.net.json
23 Nov 16:38:45 - [info] Server now running at http://127.0.0.1:1880/
23 Nov 16:38:45 - [info] +-----------------------------------------------------
23 Nov 16:38:45 - [info] | uibuilder v7.0.4 initialised 📗
23 Nov 16:38:45 - [info] | root folder: /home/pi/.node-red/uibuilder
23 Nov 16:38:45 - [info] | Using Node-RED's webserver at:
23 Nov 16:38:45 - [info] |   http://0.0.0.0:1880/
23 Nov 16:38:45 - [info] | Installed packages:
23 Nov 16:38:45 - [info] +-----------------------------------------------------
23 Nov 16:38:46 - [info] Starting flows
node id  1439c001_b8134
SecuritySystemCurrentState_1439c001_b8134
Loading Bridge node f911c6e0eaebb4e7
Trying
Not Starting yet, more devices to load
Bridge Created, awaiting child nodes
Server Ready
loading the deviceId and deviceKey from config ...
23 Nov 16:38:54 - [info] [tuya-smart-device:left blind] Setting custom log level as log-level-debug
23 Nov 16:38:54 - [info] [tuya-smart-device:left blind] Auto start probe on connect...
loading the deviceId and deviceKey from config ...
23 Nov 16:38:54 - [info] [tuya-smart-device:right blind] Setting custom log level as log-level-debug
23 Nov 16:38:54 - [info] [tuya-smart-device:right blind] Auto start probe on connect...
23 Nov 16:38:56 - [error] [function:Setup haspTheme] TypeError: flow.get(...) is not a function
23 Nov 16:38:56 - [warn] [function:Store Functions] Adding calculateGridValues function
23 Nov 16:38:56 - [warn] [function:Store Functions] Adding rowsColumns function
23 Nov 16:38:56 - [warn] [function:Store Functions] Adding findKeyByButton function
23 Nov 16:38:56 - [warn] [function:Store Functions] Adding timestamp function
23 Nov 16:38:56 - [warn] [function:Store Functions] Adding scaleBtn function
Loading Device node e043b1889a10a665
Registering Child......
Registering e043b1889a10a665 with f911c6e0eaebb4e7
{
  systemMode: 0,
  localTemperature: 0,
  controlSequenceOfOperation: 4,
  minHeatSetpointLimit: 500,
  maxHeatSetpointLimit: 3500,
  absMinHeatSetpointLimit: 500,
  absMaxHeatSetpointLimit: 3500,
  minCoolSetpointLimit: 0,
  absMinCoolSetpointLimit: 0,
  maxCoolSetpointLimit: 2100,
  absMaxCoolSetpointLimit: 2100
}
adding device to aggregator
Trying
Starting Bridge
23 Nov 16:38:56 - [info] Started flows
2024-11-23 16:38:57.672 FATAL  Logger               Unhandled error detected: MdnsService unavailable due to initialization error
  at crashedError (/home/pi/.node-red/node_modules/@project-chip/matter.js/dist/cjs/util/Construction.js:323:24)
  at handleRejection (/home/pi/.node-red/node_modules/@project-chip/matter.js/dist/cjs/util/Construction.js:114:63)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
23 Nov 16:38:57 - [red] Uncaught Exception:
23 Nov 16:38:57 - [error] Error: MdnsService unavailable due to initialization error
    at crashedError (/home/pi/.node-red/node_modules/@project-chip/matter.js/dist/cjs/util/Construction.js:323:24)
    at handleRejection (/home/pi/.node-red/node_modules/@project-chip/matter.js/dist/cjs/util/Construction.js:114:63)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Consumed 33.987s CPU time.

No you just need a matter controller like an echo.

It sounds like a network issue,
Is your node-red instance on the same local network as your echo?
Not running in docker or anything?
Have you selected the right interface on the node-red machine under the bridge config node? Eg eth0 or something?

That sounds like the same issue @Steve-Mcl was having, are you running on windows?

NR running native on my main desktop machine - two choices of interface lo and enp10s0 - neither work

Can you put the bridge config into debug and post a full log from the deploy onwards

Bridge Restarted
23 Nov 20:00:43 - [info] Stopped modified nodes
23 Nov 20:00:43 - [info] Updated flows
23 Nov 20:00:43 - [info] Starting modified nodes
Loading Bridge node e444d63a1de3babe
Trying
Not Starting yet, more devices to load
2024-11-23 20:00:43.550 DEBUG  EventHandler         Set/Restore last event number: 16
2024-11-23 20:00:43.552 INFO   ServerStore          Opened e444d63a1de3babe storage at /home/simon/.matter/e444d63a1de3babe
2024-11-23 20:00:43.554 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe>#a9 locked e444d63a1de3babe.basicInformation.state
2024-11-23 20:00:43.555 WARN   BasicInfor~ionServer Using development values for some BasicInformation attributes: hardwareVersion: 0 softwareVersion: 0
2024-11-23 20:00:43.562 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe>#a9 locked e444d63a1de3babe.accessControl.state
2024-11-23 20:00:43.566 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe>#a9 locked e444d63a1de3babe.groupKeyManagement.state
2024-11-23 20:00:43.572 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe>#a9 locked e444d63a1de3babe.generalCommissioning.state
2024-11-23 20:00:43.577 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe>#a9 locked e444d63a1de3babe.administratorCommissioning.state
2024-11-23 20:00:43.579 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe>#a9 locked e444d63a1de3babe.operationalCredentials.state
2024-11-23 20:00:43.587 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe>#a9 locked e444d63a1de3babe.generalDiagnostics.state
2024-11-23 20:00:43.594 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe>#a9 locked e444d63a1de3babe.descriptor.state
Loading Device node 7a42c97a1d48bf35
23 Nov 20:00:43 - [info] Started modified nodes
2024-11-23 20:00:43.605 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe>#a9 committed and unlocked 8 resources
2024-11-23 20:00:43.606 INFO   Endpoint             e444d63a1de3babe ready endpoint#: 0 type: RootNode (0x16) behaviors: 💤parts ✔index ✔basicInformation ✔accessControl ✔groupKeyManagement ✔generalCommissioning ✔administratorCommissioning ✔operationalCredentials ✔generalDiagnostics ✔commissioning ✔network 💤productDescription 💤sessions ✔descriptor
2024-11-23 20:00:43.607 DEBUG  Transaction          Transaction reactor<e444d63a1de3babe.commissioning.#initializeNode>#ad locked e444d63a1de3babe.commissioning.state
2024-11-23 20:00:43.607 DEBUG  Transaction          Transaction reactor<e444d63a1de3babe.commissioning.#initializeNode>#ad committed and unlocked 1 resource
Bridge Created, awaiting child nodes
Server Ready
2024-11-23 20:00:43.609 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe.aggregator>#b1 locked e444d63a1de3babe.aggregator.descriptor.state
2024-11-23 20:00:43.610 DEBUG  Transaction          Transaction reactor<e444d63a1de3babe.descriptor.#updatePartsList>#b2 locked e444d63a1de3babe.descriptor.state
2024-11-23 20:00:43.610 DEBUG  Transaction          Transaction reactor<e444d63a1de3babe.descriptor.#updatePartsList>#b2 committed and unlocked 1 resource
2024-11-23 20:00:43.611 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe.aggregator>#b1 committed and unlocked 1 resource
2024-11-23 20:00:43.612 INFO   Endpoint             e444d63a1de3babe.aggregator ready endpoint#: 1 type: Aggregator (0xe) behaviors: 💤parts ✔index ✔descriptor
Registering Child......
Registering 7a42c97a1d48bf35 with e444d63a1de3babe
adding device to aggregator
Trying
Starting Bridge
2024-11-23 20:00:43.702 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe.aggregator.7a42c97a1d48bf35>#c4 locked e444d63a1de3babe.aggregator.7a42c97a1d48bf35.identify.state
2024-11-23 20:00:43.703 WARN   ValidatedElements    Error in IdentifyServer.triggerEffect: Throws unimplemented exception
2024-11-23 20:00:43.704 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe.aggregator.7a42c97a1d48bf35>#c4 locked e444d63a1de3babe.aggregator.7a42c97a1d48bf35.groups.state
2024-11-23 20:00:43.706 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe.aggregator.7a42c97a1d48bf35>#c4 locked e444d63a1de3babe.aggregator.7a42c97a1d48bf35.onOff.state
2024-11-23 20:00:43.708 NOTICE Node                 e444d63a1de3babe going online
2024-11-23 20:00:43.708 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe.aggregator.7a42c97a1d48bf35>#c4 locked e444d63a1de3babe.aggregator.7a42c97a1d48bf35.descriptor.state
2024-11-23 20:00:43.709 DEBUG  Transaction          Transaction reactor<e444d63a1de3babe.descriptor.#updatePartsList>#c5 locked e444d63a1de3babe.descriptor.state
2024-11-23 20:00:43.709 DEBUG  Transaction          Transaction reactor<e444d63a1de3babe.aggregator.descriptor.#updatePartsList>#c6 locked e444d63a1de3babe.aggregator.descriptor.state
2024-11-23 20:00:43.710 DEBUG  Transaction          Transaction reactor<e444d63a1de3babe.descriptor.#updatePartsList>#c5 committed and unlocked 1 resource
2024-11-23 20:00:43.711 DEBUG  Transaction          Transaction reactor<e444d63a1de3babe.aggregator.descriptor.#updatePartsList>#c6 committed and unlocked 1 resource
2024-11-23 20:00:43.714 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe.aggregator.7a42c97a1d48bf35>#c4 locked e444d63a1de3babe.aggregator.7a42c97a1d48bf35.bridgedDeviceBasicInformation.state
2024-11-23 20:00:43.716 DEBUG  Transaction          Transaction initialize<e444d63a1de3babe.aggregator.7a42c97a1d48bf35>#c4 committed and unlocked 5 resources
2024-11-23 20:00:43.717 INFO   Endpoint             e444d63a1de3babe.aggregator.7a42c97a1d48bf35 ready endpoint#: 2 type: OnOffLight (0x100) behaviors: ✔identify ✔groups ✔onOff ✔bridgedDeviceBasicInformation ✔descriptor
2024-11-23 20:00:43.718 DEBUG  UdpChannelNode       Socket created and bound remoteAddress: undefined:5540 localAddress: :::5540
2024-11-23 20:00:43.720 DEBUG  Transaction          Transaction set<e444d63a1de3babe>#d8 locked e444d63a1de3babe.network.state
2024-11-23 20:00:43.720 DEBUG  Transaction          Transaction set<e444d63a1de3babe>#d8 committed and unlocked 1 resource
2024-11-23 20:00:43.721 DEBUG  UdpChannelNode       Socket created and bound remoteAddress: undefined:5540 localAddress: 0.0.0.0:5540
2024-11-23 20:00:43.721 DEBUG  Transaction          Transaction set<e444d63a1de3babe>#d9 locked e444d63a1de3babe.network.state
2024-11-23 20:00:43.721 DEBUG  Transaction          Transaction set<e444d63a1de3babe>#d9 committed and unlocked 1 resource
2024-11-23 20:00:43.723 DEBUG  MdnsBroadcaster      Announce commissioning mode 1 Test 14 65521 32768 4055 5540
2024-11-23 20:00:43.724 NOTICE Node                 e444d63a1de3babe is online
2024-11-23 20:00:43.724 DEBUG  EventHandler         Received event: {"eventNumber":"17","eventId":0,"clusterId":40,"endpointId":0,"epochTimestamp":1732392043724,"priority":2,"data":{"softwareVersion":0}}
2024-11-23 20:00:43.728 INFO   AccessControlServer  initializing ACL manager with ACL 
2024-11-23 20:00:43.729 DEBUG  Transaction          Transaction offline#da locked e444d63a1de3babe.operationalCredentials.state
2024-11-23 20:00:43.729 DEBUG  Transaction          Transaction offline#da committed and unlocked 1 resource
2024-11-23 20:00:43.729 DEBUG  MdnsBroadcaster      Announcement Generator: Commission mode mode: 1 qname: 8FEAB764EA2294CD._matterc._udp.local port: 5540 interface: lo
2024-11-23 20:00:43.730 DEBUG  Transaction          Transaction offline#da locked e444d63a1de3babe.operationalCredentials.state and e444d63a1de3babe.generalDiagnostics.state
2024-11-23 20:00:43.731 DEBUG  EventHandler         Received event: {"eventNumber":"18","eventId":3,"clusterId":51,"endpointId":0,"epochTimestamp":1732392043731,"priority":2,"data":{"bootReason":0}}
2024-11-23 20:00:43.735 NOTICE Commissioning        e444d63a1de3babe is uncommissioned passcode: 6826079 discriminator: 4055 manual pairing code: 35948704160
  ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  █ ▄▄▄▄▄ ██▀▄▀▄█ ▄▄▄▄▄ █
  █ █   █ █▄▀▄▀▄█ █   █ █
  █ █▄▄▄█ ██ ▀▀▄█ █▄▄▄█ █
  █▄▄▄▄▄▄▄█ █ ▀ █▄▄▄▄▄▄▄█
  █▄ ▄▀  ▄  ▀▄▄█▄ ███ █▀█
  █ ▀▀ ▄ ▄██▀▄  █▄▀▄ ▀█▀█
  ██▄█▄▄█▄▄█▄█  ██ ▄▄▀▄▀█
  █ ▄▄▄▄▄ █ █▀ ▄▄▄█▄▄ █ █
  █ █   █ █▄▄██▀█▀ ▀▄ ▀██
  █ █▄▄▄█ █ ▀ ███▀▀█  ▀ █
  █▄▄▄▄▄▄▄█▄█▄█▄█▄▄██▄█▄█
  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  QR code URL: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT:Y.K90SO527WVGK2I500
  
2024-11-23 20:00:43.736 DEBUG  Transaction          Transaction offline#da committed and unlocked 2 resourc

What's your main machine OS, I assume from those hostnames its Linux?
Looks like the multicast address isn't initialising which would be why Alexa can't discover the device,

If you've got another machine running Linux or Mac there on the network try this flow with the node-red-node-discovery (node) - Node-RED node

[
    {
        "id": "0d3b8f11d8ab704b",
        "type": "discovery",
        "z": "e9687f01eec1ef52",
        "name": "",
        "topic": "",
        "service": "_matterc._udp",
        "x": 90,
        "y": 20,
        "wires": [
            [
                "728a6e78438564f1"
            ]
        ]
    },
    {
        "id": "728a6e78438564f1",
        "type": "debug",
        "z": "e9687f01eec1ef52",
        "name": "debug 1",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 260,
        "y": 20,
        "wires": []
    }
]

That should output any discoverable matter devices on the network

I think you might not have exported your flow correctly?

I've just edited Sam's post. Try again Si.

1 Like

I installed that discovery node on my main Pi but unfortunately it just crashes NR :frowning:

24 Nov 09:49:24 - [info] Stopping modified nodes
24 Nov 09:49:24 - [info] Stopped modified nodes
24 Nov 09:49:24 - [info] Updated flows
24 Nov 09:49:25 - [info] Starting modified nodes
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
24 Nov 09:49:26 - [info] You may ignore the warning about Bonjour compatability.
24 Nov 09:49:26 - [info] Started modified nodes

  #  node-red[2904]: void node::cares_wrap::{anonymous}::GetAddrInfo(const v8::FunctionCallbackInfo<v8::Value>&) at ../src/cares_wrap.cc:1575
  #  Assertion failed: args[4]->IsUint32()

----- Native stack trace -----


----- JavaScript stack trace -----

1: getaddrinfo_0_11 (/home/pi/.node-red/node_modules/mdns/lib/resolver_sequence_tasks.js:117:21)
2: /home/pi/.node-red/node_modules/mdns/lib/resolver_sequence_tasks.js:153:7
3: getaddrinfo (/home/pi/.node-red/node_modules/mdns/lib/resolver_sequence_tasks.js:152:14)
4: next (/home/pi/.node-red/node_modules/mdns/lib/browser.js:109:21)
5: on_resolver_done (/home/pi/.node-red/node_modules/mdns/lib/resolver_sequence_tasks.js:33:11)
6: MDNSService.self.watcher.callback (/home/pi/.node-red/node_modules/mdns/lib/mdns_service.js:18:40)


Aborted
pi@pi128gb:~/.node-red $ 

Ok thats useful and interesting, it looks like your machine doesn't have Avahi installed which is the open-source mDNS stack.

Which would also explain why the Matter nodes can't broadcast their availibilty.

What OS is it? Could you try installing Avahi?

1 Like

Sorry _ i thought you asked me to install it on a different machine to the one I was trying the bridge on.

Just to clarify - I've got the bridge installed on my main Linux Mint desktop machine

I installed the discovery node on a Pi

Should I be running the discovery node on the same machine as the bridge?

Sorry yes realised that after I'd written the response(although also interesting it doesn't have avahi)
Try the discover node on your desktop machine and see if you get the same error.
I think it should discover the matter node on the same machine anyway but it doesn't quite prove the messages are making it across your network that way.

Unfortunaley, we are just going further down a rabbit hole :frowning:
Installed discovery node on main desktop machine and it too crashed
Checked and avahi-demon is installed

simon@simon-HP-Desktop-M01-F1xxx:~/.node-red$ sudo apt install avahi-daemon
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
avahi-daemon is already the newest version (0.8-5ubuntu5.2).

Checked my pi as well as its installed there as well

pi@pi128gb:~ $ sudo apt install avahi-daemon
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
avahi-daemon is already the newest version (0.8-5+deb11u2).
0 upgraded, 0 newly installed, 0 to remove and 225 not upgraded.
pi@pi128gb:~ $ 
1 Like

Hmm all very strange, I'm away at the moment but I'll do a clean test run on a dev setup when I get home as close as I can you your setup.
So you have Node-RED running nativly on a Mint Linux machine? Which version?

Only other thing to suggest is running matter on the Pi, that should work fine as I do most of my dev & testing with it on Pi's and Mac

I'll also try the discover node on a Pi and see if I get those errors.

4.0.1 - I'll upgrade to latest and try again

I was meaning which version of Mint Linux, NodeRED wise it shouldn't make a huge difference, so long as you're on Node18+

There's quite a bit in Matter that relies on lower level OS stuff like networking so debugging these nodes on different platforms is complicated