npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-matter

v0.0.10

Published

Matter protocol for node.js

Downloads

115

Readme

node-matter

license

Matter protocol for node.js with no native dependencies (and very limited dependencies).

Matter is a new secure / reliable / local / standard protocol for smart devices that will launch at the end of 2022.

It is supported and Google / Apple / Amazon and 200+ other companies and it is supposed to bring a revolution in smart home automation by unifying WiFi / Bluetooth / Zigbee (through Thread) and by making all smart devices inter-compatible and secure (through the standard and secure Matter protocol).

To know more about Matter: https://csa-iot.org/all-solutions/matter/

This package requires Node 16+ for the required Crypto primitives

Installation

npm i -g node-matter

Usage

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).

Modifying the server behavior

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()

What can I use to control my device?

It should work with any Matter-compatible home automation app when Matter will be released.

chip-tool

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

Android mobile app

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

FAQ

Why using node-matter instead of the official codebase?

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.

Can this work from a browser?

Not yet, but I know how to make it works with a few tricks.

How can I have support for more clusters?

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.

Contact the author

For other questions, you can reach out to: [email protected] or post a message on the github forum.