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-broadlink

v2.4.0

Published

A promise based Node.js module for Broadlink controllers

Downloads

416

Readme

Node.JS library for Broadlink controllers

A promise based Node.js module created from Python API python-broadlink for controlling Broadlink IR/RF controllers.

Example use

Setup a new device on your local wireless network:

  1. Put the device into AP Mode
  2. Long press the reset button until the blue LED is blinking quickly.
  3. Long press again until blue LED is blinking slowly.
  4. Manually connect to the WiFi SSID named BroadlinkProv.
  5. Run setup() and provide your ssid, network password (if secured), and set the security mode
  6. Security mode options are (0 = none, 1 = WEP, 2 = WPA1, 3 = WPA2, 4 = WPA1/2)
import * as broadlink from 'node-broadlink';

broadlink.setup('myssid', 'mynetworkpass', 3)

Discover available devices on the local network:

import * as broadlink from 'node-broadlink';

const [device] = await broadlink.discover();

Obtain the authentication key required for further communication:

await device.auth();

Enter learning mode:

import { Rmmini } from 'node-broadlink';
const rmminiDevice = device as Rmmini;
await rmminiDevice.enterLearning();

Sweep RF frequencies:

import { Rmpro } from 'node-broadlink';
const rmproDevice = device as Rmpro;
const responseRaw = await rmproDevice.sweepFrequency();

Cancel sweep RF frequencies:

const responseRaw = await rmproDevice.cancelSweepFrequency();

Check whether a frequency has been found:

const found = await rmproDevice.checkFrequency();

(This will return true if the RM has locked onto a frequency, false otherwise)

Attempt to learn an RF packet:

const found = await rmproDevice.findRfPacket();

(This will return true if a packet has been found, false otherwise)

Obtain an IR or RF packet while in learning mode:

const ir_packet = await rmminiDevice.checkData(); // 2600d80000012894133814381312131213121312.....

(This will reject an error if the device does not have a packet to return)

Send an IR or RF packet:

// ir_packet can be an hex-string (e.g "2600d80000012894133814381312131....") or a numbers array (e.g. [74, 7, 212, 7, 17, 161, 184, 70, 118, 205, ....]) 
const responseRaw = await rmminiDevice.sendData(ir_packet);

Obtain temperature data from an RM2:

const temperature = await rmproDevice.checkTemperature(); // 45.5

Obtain sensor data from an A1:

import { A1 } from 'node-broadlink';
const a1Device = device as A1;
const data = await a1Device.checkSensors();

Set power state on a SmartPlug SP2/SP3:

import { Sp2 } from 'node-broadlink';
const sp2Device = device as Sp2;
const responseRaw = await sp2Device.setPower(true);

Check power state on a SmartPlug:

const state = await sp2Device.checkPower();

Check energy consumption on a SmartPlug:

import { Sp2s } from 'node-broadlink';
const sp2sDevice = device as Sp2s;
const state = await sp2sDevice.getEnergy();

Set power state for S1 on a SmartPowerStrip MP1:

import { Mp1 } from 'node-broadlink';
const mp1Device = device as Mp1;
const responseRaw = await mp1Device.setPower(1, true);

Check power state on a SmartPowerStrip:

const state = await mp1Device.checkPower();