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

misfit-bolt

v2.0.1

Published

Misfit Bolt Javascript Interface

Downloads

44

Readme

Misfit Bolt Javascript Interface Build status

Implementation of sandeepmistry/noble-device, that helps driving a Misfit Bolt LED bluetooth bulbs.

Largely inspired by fayep's Python implementation, and sandeepmistry's YeeLight Bluetooth implementation.

Based on Yeelight Blue Message Interface specifications.

Features

  • Control of color via RGBA and HSB schemes.
  • Control of state, with in-bulb persistence of last color set, and in-app persistence of last brightness set.
  • Control of gradual effect transition (progressive or immediate).
  • Control of the bluetooth name of the bulb.

Prerequisites

To connect to the Misfit Bolt, you need BLE capabilities. See sandeepmistry/noble prerequisites for more details.

Setup

npm install misfit-bolt

Developer

npm run lint
npm run doc-lint
npm run doc-gen
npm test

API

Bolt

Parameters

  • peripheral

setRGBA

Set RGBA values of the bolt.

Parameters

  • rgba Array<number> Red (0 to 255) / Green (0 to 255) / Blue (0 to 255) / Alpha (0 to 100) values
  • done ?SimpleCallback completion callback

Examples

bolt.setRGBA([255, 0, 0, 10], function(error) {
  console.log('Bolt now set to red !');
});

Returns Bolt

getRed

Retrieve Red value of the bolt.

Parameters

  • done NumberGetterCallback completion callback

Examples

bolt.getRed(function(error, red) {
  console.log('Current Red value is: ', red);
});

Returns Bolt

setRed

Set Red value of the bolt.

Parameters

  • red number Red value (0 to 255)
  • done ?SimpleCallback completion callback

Examples

bolt.setRed(10, function(error) {
  console.log('Red is now set to 10');
});

Returns Bolt

getGreen

Retrieve Green value of the bolt.

Parameters

  • done NumberGetterCallback completion callback

Examples

bolt.getGreen(function(error, green) {
  console.log('Current Green value is: ', green);
});

Returns Bolt

setGreen

Set Green value of the bolt.

Parameters

  • green number Green value (0 to 255)
  • done ?SimpleCallback completion callback

Examples

bolt.setGreen(10, function(error) {
  console.log('Green is now set to 10');
});

Returns Bolt

getBlue

Retrieve Blue value of the bolt.

Parameters

  • done NumberGetterCallback completion callback

Examples

bolt.getBlue(function(error, blue) {
  console.log('Current Blue value is: ', blue);
});

Returns Bolt

setBlue

Set Blue value of the bolt.

Parameters

  • blue number Blue value (0 to 255)
  • done ?SimpleCallback completion callback

Examples

bolt.setBlue(10, function(error) {
  console.log('Blue is now set to 10');
});

Returns Bolt

getAlpha

Retrieve Alpha value of the bolt.

Parameters

  • done NumberGetterCallback completion callback

Examples

bolt.getAlpha(function(error, alpha) {
  console.log('Current Alpha value is: ', alpha);
});

Returns Bolt

setAlpha

Set Alpha value of the bolt.

Parameters

  • alpha number Alpha value (0 to 100)
  • done ?SimpleCallback completion callback

Examples

bolt.setAlpha(10, function(error) {
  console.log('Alpha is now set to 10');
});

Returns Bolt

getHSB

Retrieve Hue, Saturation and Brightness values of the bolt in the form of an Array of Integers.

Parameters

  • done NumbersGetterCallback completion callback

Examples

bolt.getHSB(function(error, hsb) {
  console.log('Current HSB values are: ', hsb);
});

Returns Bolt

setHSB

Set HSB values of the bolt.

Parameters

  • rgba Array<number> Hue (0 to 360) / Saturation (0 to 100) / Brightness (0 to 100) values
  • done ?SimpleCallback completion callback

Examples

bolt.setHSB([0, 100, 10], function(error) {
  console.log('Bolt now set to red !');
});

Returns Bolt

getHue

Retrieve Hue value of the bolt.

Parameters

  • done NumberGetterCallback completion callback

Examples

bolt.getHue(function(error, hue) {
  console.log('Current Hue value is: ', hue);
});

Returns Bolt

setHue

Set Hue value of the bolt.

Parameters

  • hue number Hue value (0 to 360)
  • done ?SimpleCallback completion callback

Examples

bolt.setHue(10, function(error) {
  console.log('Hue is now set to 10');
});

Returns Bolt

getSaturation

Retrieve Saturation value of the bolt.

Parameters

  • done NumberGetterCallback completion callback

Examples

bolt.getSaturation(function(error, saturation) {
  console.log('Current Saturation value is: ', saturation);
});

Returns Bolt

setSaturation

Set Saturation value of the bolt.

Parameters

  • saturation number Saturation value (0 to 100)
  • done ?SimpleCallback completion callback

Examples

bolt.setSaturation(10, function(error) {
  console.log('Saturation is now set to 10');
});

Returns Bolt

getBrightness

Retrieve Brightness value of the bolt.

Parameters

  • done NumberGetterCallback completion callback

Examples

bolt.getBrightness(function(error, brightness) {
  console.log('Current Brightness value is: ', brightness);
});

Returns Bolt

setBrightness

Set Brightness value of the bolt.

Parameters

  • brightness number Brightness value (0 to 100)
  • done ?SimpleCallback completion callback

Examples

bolt.setBrightness(10, function(error) {
  console.log('Brightness is now set to 10');
});

Returns Bolt

getState

Retrieve State value of the bolt.

Parameters

  • done BooleanGetterCallback completion callback

Examples

bolt.getState(function(error, state) {
  console.log(`Bolt is ${state ? 'on' : 'off'}`);
});

Returns Bolt

setState

Set State value of the bolt.

Parameters

  • state boolean State value
  • done ?SimpleCallback completion callback

Examples

bolt.setState(true, function(error) {
  console.log(`Bolt is now on !`);
});

Returns Bolt

getGradualMode

Retrieve Gradual Mode value of the bolt. Indicates whether transition between states is progressive or immediate.

Parameters

  • done BooleanGetterCallback completion callback

Returns Bolt

setGradualMode

Set Gradual Mode value of the bolt.

Parameters

  • gradualMode boolean Gradual Mode value
  • done ?SimpleCallback completion callback

Returns Bolt

getName

Retrieve Name value of the bolt (as visible by the Bluetooth client).

Parameters

  • done StringGetterCallback completion callback

Returns Bolt

setName

Set Name value of the bolt.

Parameters

  • name string Name value
  • done ?SimpleCallback completion callback

Returns Bolt

getRGBA

Retrieve Red, Green, Blue and Alpha values of the bolt in the form of an Array of Integers.

Parameters

  • done Function completion callback
  • done NumbersGetterCallback completion callback

Examples

bolt.getRGBA(function(error, rgba) {
  console.log('Current RGBA values are: ', rgba);
});

Returns Bolt

init

Starts the discovery loop. Loop consist in stopping and starting the Bolt discovery process every DISCOVERY_LOOP_MS. This is to paliate a potential issue with Noble device that becomes stale after a few hours and loose connection with connected bolt / stop detecting previously disconnected bolts.

Examples

Bolt.init(function(error, rgba) {
  console.log('Current RGBA values are: ', rgba);
});

get

Retrieve an bolt from internal registry.

Parameters

Examples

let bolt = Bolt.get('2312AC5C08E348699B0199458AC644BD');
bolt.setState(true, function() {
  ...
});

Returns Bolt?

remove

Remove an bolt from internal registry.

Parameters

Examples

let bolt = Bolt.remove('2312AC5C08E348699B0199458AC644BD');

Returns boolean

SimpleCallback

Simple completion callback

Parameters

  • Error ?Error while performing async operation

NumbersGetterCallback

Numbers getter completion callback

Parameters

NumberGetterCallback

Number getter completion callback

Parameters

  • Error ?Error while performing async operation
  • Value ?Number retrieved

BooleanGetterCallback

Boolean getter completion callback

Parameters

  • Error ?Error while performing async operation
  • Value ?Boolean retrieved

StringGetterCallback

String getter completion callback

Parameters

  • Error ?Error while performing async operation
  • Value ?String retrieved

TODO

  • CLI tool

Notes

  • PRs welcomed!