New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

node-smartplay

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-smartplay

A JavaScript/TypeScript module for LEGO Smart Play BLE devices

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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)

MethodDescription
scan()Start scanning for Smart Play devices.
stop()Stop scanning.
getDevice(uuid)Get a discovered device by UUID.
getDevices()Get all discovered devices.
EventDescription
discoverEmitted when a device is found. Provides a SmartBrickDevice instance.

SmartBrickDevice

MethodDescription
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.
PropertyTypeDescription
batterynumberCurrent battery level (%).
volumenumberCurrent volume level.
connectedbooleanWhether the device is connected.
infoSmartBrickInfoDevice identity (name, model, firmware, MAC, UUID).
EventDescription
batteryEmitted when the battery level changes.
volumeEmitted when the volume changes.
connectionStateEmitted when the charging/connection state changes.
disconnectEmitted when the device disconnects.

Compatibility

DeviceStatusNotes
Smart BrickSupportedBattery, 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

Keywords

lego

FAQs

Package last updated on 03 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts