Matter protocol for node.js with no native dependencies (and very limited dependencies).
This package requires Node 16+ for the required Crypto primitives
Matter is a new secure / reliable / local / standard protocol for smart devices launched at the end of 2022. To know more about Matter: https://csa-iot.org/all-solutions/matter/
node-matter is compatible with (or will soon be):
- iOS - Home app: fully working, screenshot
- Android - Home app: fully working, thread
- Alexa: fully working, screenshot
- Home Assistant: was working, we are on it, thread
npm i -g node-matter
matter
This starts a Matter server listening on port 5540.
This first version only includes the OnOff cluster (on/off smart thing, like a plug or a bulb). You can use -on and -off parameter to run a script to control something. For instance, on a Raspberry Pi, this will turn on / off the red LED:
matter -on "echo 255 > /sys/class/leds/led1/brightness" -off "echo 0 > /sys/class/leds/led1/brightness"
Experimental
matter-controller -ip [IP address of device to commission]
This will commission a Matter device (for debugging purpose only for now).
Main.ts defines the server behavior. You can add / remove clusters, change default parameters, etc...
new MatterServer()
.addChannel(new UdpChannel(5540))
.addProtocolHandler(Protocol.SECURE_CHANNEL, new SecureChannelHandler(
new PasePairing(20202021, { iteration: 1000, salt: Crypto.getRandomData(32) }),
new CasePairing(),
))
.addProtocolHandler(Protocol.INTERACTION_MODEL, new InteractionProtocol(new Device([
new Endpoint(0x00, "MA-rootdevice", [
new BasicInformationCluster({ vendorName: "node-matter", vendorId: 0xFFF1, productName: "Matter test device", productId: 0X8001 }),
new GeneralCommissioningCluster(),
new OperationalCredentialsCluster(),
]),
new Endpoint(0x01, "MA-OnOff", [
new OnOffCluster(executor("on"), executor("off")),
]),
])))
.start()
It should work with any Matter-compatible home automation app when Matter will be released.
Compile chip-tool from project-chip
Provisioning the device:
chip-tool pairing onnetwork 222 20202021
Controlling the device:
chip-tool onoff toggle 222 1
Clearing the data:
chip-tool pairing unpair 222
and/or
chip-tool storage clear-all
You can also control it with Matter test app: https://github.com/project-chip/connectedhomeip/tree/master/src/android/CHIPTest You can find a compiled apk in /matter-test-apk in this repository.
Provisioning the device: click "provision with WiFi" > "Input Device address" > type IP address of the machine running node-matter
Controlling the device: click "Light on/of" and you can control the light
Well, the original codebase is platform dependent, has finicky tool version requirements and is over 8GB with all dependencies. This tool is less than 500kB and works on anything supporting node. Sure, it supports only the barebone Matter protocol for now.
Not yet, but I know how to make it works with a few tricks.
Adding more clusters should be pretty easy now the core protocol is working. Have a look at the implementation of the OnOff cluster: pretty simple, right?
I am planning on adding more clusters, so stay tuned or pinged me to implement first the one you need.
For other questions, you can reach out to: [email protected] or post a message on the github forum.