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.
- 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.
To connect to the Misfit Bolt, you need BLE capabilities. See sandeepmistry/noble prerequisites for more details.
npm install misfit-boltnpm run lint
npm run doc-lint
npm run doc-gen
npm testParameters
peripheral
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Retrieve Gradual Mode value of the bolt. Indicates whether transition between states is progressive or immediate.
Parameters
doneBooleanGetterCallback completion callback
Returns Bolt
Set Gradual Mode value of the bolt.
Parameters
gradualModeboolean Gradual Mode valuedone?SimpleCallback completion callback
Returns Bolt
Retrieve Name value of the bolt (as visible by the Bluetooth client).
Parameters
doneStringGetterCallback completion callback
Returns Bolt
Set Name value of the bolt.
Parameters
namestring Name valuedone?SimpleCallback completion callback
Returns Bolt
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
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);
});Retrieve an bolt from internal registry.
Parameters
idstring bolt identifier
Examples
let bolt = Bolt.get('2312AC5C08E348699B0199458AC644BD');
bolt.setState(true, function() {
...
});Returns Bolt?
Remove an bolt from internal registry.
Parameters
idstring bolt identifier
Examples
let bolt = Bolt.remove('2312AC5C08E348699B0199458AC644BD');Returns boolean
Simple completion callback
Parameters
Error?Error while performing async operation
Numbers getter completion callback
Parameters
Number getter completion callback
Parameters
Boolean getter completion callback
Parameters
String getter completion callback
Parameters
- CLI tool
- PRs welcomed!