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

@meross/lib

v2.0.2

Published

Library for interacting with Meross devices

Readme

Meross Library

A TypeScript/JavaScript library for interacting with Meross smart home devices.

Installation

npm install @meross/lib

Basic Usage

import { HTTPTransport, Device, CloudCredentials } from '@meross/lib';

async function main() {
  // Setup credentials (use userId: 0 and key: 'meross' for local devices)
  const credentials = new CloudCredentials(0, 'meross');

  // Create HTTP transport
  const transport = new HTTPTransport({
    url: 'http://192.168.1.100/config',
    credentials,
  });

  // Initialize device
  const device = new Device();
  device.setTransport(transport);

  // Get device information
  const deviceInfo = await device.fetchDeviceInfo();
  console.log('Device Info:', deviceInfo);

  // Get device abilities
  const abilities = await device.fetchDeviceAbilities();
  console.log('Device Abilities:', abilities);
}

main().catch(console.error);

Core Components

Device

The Device class is the primary interface for communicating with Meross devices:

import { Device, WifiAccessPoint, CloudCredentials } from '@meross/lib';

// Create device instance
const device = new Device();

// Connect to device
device.setTransport(transport);

// Fetch device information
const info = await device.fetchDeviceInfo();

// Check device abilities
const abilities = await device.fetchDeviceAbilities();

// Check if device has a specific ability
const hasEncryption = device.hasAbility(Namespace.ENCRYPT_ECDHE);

// Configure WiFi
const wifiAP = new WifiAccessPoint({
  ssid: 'MyNetwork',
  password: 'MyPassword',
  encryption: 3,
  cipher: 1,
});
await device.configureWifi(wifiAP);

// Configure MQTT brokers
const credentials = new CloudCredentials(123, 'sharedKey');
await device.configureMQTTBrokersAndCredentials(
  ['mqtt://broker.example.com'],
  credentials
);

// Configure device time
await device.configureDeviceTime(
  Date.now() / 1000,
  Intl.DateTimeFormat().resolvedOptions().timeZone
);

// Get nearby WiFi networks
const nearbyNetworks = await device.fetchNearbyWifi();

Transport

The library includes an HTTP transport for device communication:

import { HTTPTransport, CloudCredentials } from '@meross/lib';

// Create credentials
const credentials = new CloudCredentials(0, 'meross');

// Create transport with device URL
const transport = new HTTPTransport({
  url: 'http://192.168.1.100/config',
  credentials,
  timeout: 15000, // Optional custom timeout (default: 10000ms)
});

Device Manager

For managing multiple devices:

import { DeviceManager, HTTPTransport, Device } from '@meross/lib';

// Create shared transport
const transport = new HTTPTransport({
  url: 'http://192.168.1.100/config',
  credentials: { userId: 0, key: 'meross' },
});

// Create device manager
const deviceManager = new DeviceManager({ transport });

// Add devices
const device1 = new Device();
deviceManager.addDevice(device1);

// Get all devices
const devices = deviceManager.getDevices();

// Get specific device
const device = deviceManager.getDeviceById('device-uuid');

// Send message to device
const message = new Message();
await deviceManager.sendMessageToDevice(device, message);

Encryption

The library supports ECDH key exchange for encrypted communication:

import {
  generateKeyPair,
  createKeyPair,
  computePresharedPrivateKey,
} from '@meross/lib';

// Method 1: Generate new key pair
const { privateKey, publicKey } = await generateKeyPair();

// Method 2: Create key pair from existing private key
const keyPair = await createKeyPair(privateKey);

// Method 3: Use precomputed key based on device info
const precomputedKey = computePresharedPrivateKey(
  deviceId,
  sharedKey,
  macAddress
);

// Configure device with private key
await device.setPrivateKey(Buffer.from(privateKeyBase64, 'base64'));

// Exchange keys with the device
await device.exchangeKeys();

WiFi Configuration

Configure a device's WiFi connection:

import { WifiAccessPoint } from '@meross/lib';

// Create WiFi access point configuration
const wifiConfig = new WifiAccessPoint({
  ssid: 'MyNetworkName',
  password: 'MySecurePassword',
  encryption: 3, // WPA2 PSK
  cipher: 1, // CCMP (AES)
  channel: 6, // 2.4GHz channel
  bssid: '00:11:22:33:44:55', // Optional
});

// Configure device
await device.configureWifi(wifiConfig);

MQTT Configuration

Configure a device to connect to MQTT brokers:

import { CloudCredentials } from '@meross/lib';

// Create credentials
const credentials = new CloudCredentials(userId, sharedKey);

// Configure MQTT brokers (supports up to 2 brokers)
const mqttServers = [
  'mqtt://primary-broker.example.com:1883',
  'mqtts://backup-broker.example.com:8883',
];

await device.configureMQTTBrokersAndCredentials(mqttServers, credentials);

Error Handling

try {
  await device.fetchDeviceInfo();
} catch (error) {
  console.error('Error communicating with device:', error.message);

  // For detailed logs
  if (process.env.LOG_LEVEL) {
    console.error('Error stack:', error.stack);
  }
}

Advanced Example: Complete Device Setup

import {
  HTTPTransport,
  Device,
  WifiAccessPoint,
  CloudCredentials,
  Namespace,
  generateTimestamp,
  computePresharedPrivateKey,
} from '@meross/lib';

async function setupDevice(ip, wifiSettings, mqttServers) {
  // Create credentials and transport
  const credentials = new CloudCredentials(0, 'meross');
  const transport = new HTTPTransport({
    url: `http://${ip}/config`,
    credentials,
  });

  // Initialize device
  const device = new Device();
  device.setTransport(transport);

  // Get device info
  const deviceInfo = await device.fetchDeviceInfo();
  console.log(`Connected to ${deviceInfo.system.hardware.type}`);

  // Get abilities
  await device.fetchDeviceAbilities();

  // Set up encryption if supported
  if (device.hasAbility(Namespace.ENCRYPT_ECDHE)) {
    // Use pre-computed key based on device information
    const privateKey = computePresharedPrivateKey(
      device.id,
      credentials.key,
      device.hardware.macAddress
    );

    await device.setPrivateKey(Buffer.from(privateKey, 'base64'));
    await device.exchangeKeys();
    console.log('Encryption keys exchanged');
  }

  // Configure time
  const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
  const time = generateTimestamp();
  await device.configureDeviceTime(time, timezone);
  console.log('Device time configured');

  // Configure MQTT (if provided)
  if (mqttServers && mqttServers.length) {
    await device.configureMQTTBrokersAndCredentials(mqttServers, credentials);
    console.log('MQTT servers configured');
  }

  // Configure WiFi (if provided)
  if (wifiSettings) {
    const wifiAccessPoint = new WifiAccessPoint(wifiSettings);
    const success = await device.configureWifi(wifiAccessPoint);

    if (success) {
      console.log('WiFi configured successfully, device will reboot');
    }
  }

  return device;
}

// Usage example
setupDevice(
  '10.10.10.1',
  {
    ssid: 'HomeNetwork',
    password: 'SecurePassword',
    encryption: 3,
    cipher: 1,
    channel: 6,
  },
  ['mqtts://broker.example.com:8883']
).catch(console.error);

API Reference

See the TypeScript definitions for complete API details.

Main Classes

  • Device - Core class for interacting with Meross devices
  • DeviceManager - Manages multiple devices with a shared transport
  • HTTPTransport - HTTP communication transport
  • CloudCredentials - Authentication credentials
  • WifiAccessPoint - WiFi configuration

Namespaces

The library defines standard Meross namespace constants in Namespace:

import { Namespace } from '@meross/lib';

// Examples:
Namespace.SYSTEM_ALL;
Namespace.SYSTEM_ABILITY;
Namespace.ENCRYPT_ECDHE;
Namespace.CONFIG_WIFI;

License

ISC