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

@mibridge/core

v1.0.2

Published

[![npm version](https://img.shields.io/npm/v/@mibridge/core.svg)](https://www.npmjs.com/package/@mibridge/core) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![TypeScript](https://img.shields.io

Readme

@mibridge/core

npm version License: MIT TypeScript Node.js Open Source

TypeScript SDK for controlling Xiaomi smart home devices via the Xiaomi Cloud API. Provides a typed, event-driven interface with device states normalized against the Matter specification.

Part of the mibridge project.

Installation

npm install @mibridge/core

Requirements

  • Node.js 18 or later
  • A Xiaomi account with devices linked to it

Usage

Authentication

import { MiCloudAuth, saveSession } from "@mibridge/core";

const auth = new MiCloudAuth({ region: "de" });
await auth.login("[email protected]", "yourpassword");

const session = auth.getSession();
await saveSession(session);

Listing devices

import { listDevices, loadSession } from "@mibridge/core";

const session = await loadSession();
const devices = await listDevices(session);
console.log(devices);

Controlling a device

import { DreameVacuumClient, CleanMode, WaterLevel } from "@mibridge/core";

const client = new DreameVacuumClient({
  deviceId: "your-device-id",
  region: "de",
});

await client.connect();

// Listen to state changes
client.on("statusChange", (status) => {
  console.log(status.state, status.batteryLevel);
});

client.on("operationComplete", (result) => {
  console.log(`Cleaned for ${result.durationMs}ms`);
});

// Control
await client.setCleanMode(CleanMode.VacuumThenMop);
await client.setWaterLevel(WaterLevel.Medium);
await client.start();

// Targeted room cleaning
const areas = await client.getAreas();
await client.startCleaningAreas(["room-1", "room-2"], {
  suction: "strong",
  repeat: 1,
});

await client.disconnect();

API

DreameVacuumClient

Main client class, extends EventEmitter.

Constructor options

| Option | Type | Description | |---|---|---| | deviceId | string | Device ID from your Xiaomi account | | region | string | Cloud region (cn, de, eu, ...) | | pollInterval | number | Status poll interval in ms (default: 5000) |

Methods

| Method | Description | |---|---| | connect() | Authenticate and start polling | | disconnect() | Stop polling and release resources | | getStatus() | Get current device status | | start() | Start cleaning | | pause() | Pause cleaning | | resume() | Resume cleaning | | stop() | Stop and stay in place | | returnToDock() | Return to charging dock | | startMapping() | Start a mapping run | | setCleanMode(mode) | Set clean mode | | setWaterLevel(level) | Set water level | | getMaps() | Get available maps | | getAreas(mapId?) | Get rooms/areas for a map | | startCleaningAreas(ids, opts?) | Clean specific rooms | | getBatteryLevel() | Get battery percentage | | getInfo() | Get device model and firmware info |

Events

| Event | Payload | Description | |---|---|---| | connected | — | Client connected | | disconnected | — | Client disconnected | | statusChange | VacuumStatus | Full status update | | stateChange | VacuumState | State changed | | cleanModeChange | CleanMode | Clean mode changed | | areaChange | string \| null | Current area changed | | progressUpdate | AreaProgress[] | Area progress update | | operationComplete | OperationResult | Cleaning session ended | | error | VacuumError | Error occurred |

Enums

enum VacuumState {
  Idle, Cleaning, Mapping, Returning, Docked, Paused, Error
}

enum CleanMode {
  Vacuum, Mop, VacuumThenMop
}

enum WaterLevel {
  Off, Low, Medium, High
}

Session management

import { saveSession, loadSession, clearSession } from "@mibridge/core";

await saveSession(session);         // persist to disk
const session = await loadSession(); // load from disk
await clearSession();               // delete session file

Sessions are stored in ~/.config/xiaomi-cli/session.json by default. Override with the XIAOMI_SESSION_DIR environment variable.

Matter Alignment

Error codes are mapped to Matter ServiceArea cluster semantics, making it straightforward to expose device state to Matter-compatible controllers without custom error handling logic.

| Matter enum | Condition | |---|---| | DustBinMissing / DustBinFull | Dust bin errors | | WaterTankEmpty / WaterTankMissing / WaterTankLidOpen | Water tank errors | | MopPadMissing | Mop pad not installed | | BatteryLow | Low battery threshold reached | | Stuck / BrushJammed / NavigationObscured | Movement errors |

Supported devices

  • dreame.vacuum.r2205
  • dreame.vacuum.p2028
  • dreame.vacuum.p2029
  • dreame.vacuum.p2114
  • dreame.vacuum.p2150a
  • dreame.vacuum.p2150b

Contributing

Contributions are welcome. Please open an issue before submitting a pull request for significant changes.

License

MIT — see LICENSE for details.