misfit-bolt v2.0.1
Misfit Bolt Javascript Interface 
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-boltDeveloper
npm run lint
npm run doc-lint
npm run doc-gen
npm testAPI
Bolt
Parameters
peripheral
setRGBA
Set RGBA values of the bolt.
Parameters
rgbaArray<number> Red (0 to 255) / Green (0 to 255) / Blue (0 to 255) / Alpha (0 to 100) valuesdone?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
doneNumberGetterCallback 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
rednumber 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
doneNumberGetterCallback 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
greennumber 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
doneNumberGetterCallback 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
bluenumber 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
doneNumberGetterCallback 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
alphanumber 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
doneNumbersGetterCallback 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
rgbaArray<number> Hue (0 to 360) / Saturation (0 to 100) / Brightness (0 to 100) valuesdone?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
doneNumberGetterCallback 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
huenumber 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
doneNumberGetterCallback 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
saturationnumber 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
doneNumberGetterCallback 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
brightnessnumber 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
doneBooleanGetterCallback 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
stateboolean State valuedone?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
doneBooleanGetterCallback completion callback
Returns Bolt
setGradualMode
Set Gradual Mode value of the bolt.
Parameters
gradualModeboolean Gradual Mode valuedone?SimpleCallback completion callback
Returns Bolt
getName
Retrieve Name value of the bolt (as visible by the Bluetooth client).
Parameters
doneStringGetterCallback completion callback
Returns Bolt
setName
Set Name value of the bolt.
Parameters
namestring Name valuedone?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
doneFunction completion callbackdoneNumbersGetterCallback 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
idstring bolt identifier
Examples
let bolt = Bolt.get('2312AC5C08E348699B0199458AC644BD');
bolt.setState(true, function() {
...
});Returns Bolt?
remove
Remove an bolt from internal registry.
Parameters
idstring bolt identifier
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
BooleanGetterCallback
Boolean getter completion callback
Parameters
StringGetterCallback
String getter completion callback
Parameters
TODO
- CLI tool
Notes
- PRs welcomed!
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago