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 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-smartplay

v1.0.0

Published

A JavaScript/TypeScript module for LEGO Smart Play BLE devices

Readme

node-smartplay — A JavaScript/TypeScript module for LEGO Smart Play BLE devices

Introduction

node-smartplay lets you discover and interact with LEGO Smart Play devices over Bluetooth Low Energy.

Currently supports the Smart Brick (audio-equipped brick). Additional device types will be supported as they are discovered.

Sample Usage

const { SmartPlay } = require("node-smartplay");

const smartPlay = new SmartPlay();

smartPlay.on("discover", async (device) => { // Wait to discover a device
    console.log("Found device, connecting...");
    await device.connect();

    const info = device.info;
    console.log(`  Name:     ${info.name}`);
    console.log(`  Model:    ${info.model}`);
    console.log(`  Firmware: ${info.firmware}`);
    console.log(`  MAC:      ${info.mac}`);
    console.log(`  Battery:  ${device.battery}%`);
    console.log(`  Volume:   ${device.volume}`);

    await device.setVolumeLow(); // Set volume to low (10)
    console.log("Volume set to low");

    device.disconnect();
});

smartPlay.scan(); // Start scanning for Smart Play devices
console.log("Scanning for Smart Play devices...");

More examples in the examples/ directory.

Installation

Node.js v18+ required.

npm install node-smartplay --save

node-smartplay uses @stoprocent/noble for BLE. See noble prerequisites.

API

SmartPlay (Scanner)

| Method | Description | | ------ | ----------- | | scan() | Start scanning for Smart Play devices. | | stop() | Stop scanning. | | getDevice(uuid) | Get a discovered device by UUID. | | getDevices() | Get all discovered devices. |

| Event | Description | | ----- | ----------- | | discover | Emitted when a device is found. Provides a SmartBrickDevice instance. |

SmartBrickDevice

| Method | Description | | ------ | ----------- | | connect() | Connect and perform the handshake sequence. | | disconnect() | Disconnect from the device. | | readBattery() | Read the current battery level (%). | | readVolume() | Read the current volume level. | | readModel() | Read the device model name. | | readFirmwareRevision() | Read the firmware version string. | | setVolume(level) | Set volume to a VolumeLevel value. | | setVolumeHigh() | Set volume to high (100). | | setVolumeMedium() | Set volume to medium (40). | | setVolumeLow() | Set volume to low (10). | | setName(name) | Set the device name (max 12 bytes UTF-8). | | readRawRegister(register) | Read a raw register value for exploration. |

| Property | Type | Description | | -------- | ---- | ----------- | | battery | number | Current battery level (%). | | volume | number | Current volume level. | | connected | boolean | Whether the device is connected. | | info | SmartBrickInfo | Device identity (name, model, firmware, MAC, UUID). |

| Event | Description | | ----- | ----------- | | battery | Emitted when the battery level changes. | | volume | Emitted when the volume changes. | | connectionState | Emitted when the charging/connection state changes. | | disconnect | Emitted when the device disconnects. |

Compatibility

| Device | Status | Notes | | ------ | ------ | ----- | | Smart Brick | Supported | Battery, volume, naming, device info. Authentication not yet supported (requires LEGO backend signing). |

Known Limitations

  • Authentication — ECDSA P-256 challenge-response requires LEGO's backend signing server. Device info, volume, and naming work without auth. Firmware updates and factory reset require it.

  • Docked only — Devices are only connectable while on the charging base. Undocked, they use BLE 5.4 PAwR for device-to-device play and aren't visible to BLE scanners.

  • Rotating BLE addresses — The stable identifier is the MAC address, available via device.info.mac after connecting.

  • Linux permissions — You may need to grant node access to the Bluetooth adapter.

Reverse Engineering Notes

The notes/ directory contains reverse engineering documentation for the Smart Play BLE protocol, hardware, backend API, and file transfer system.

Development

npm install
npm run build