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-bolt
Developer
npm run lintnpm run doc-lintnpm run doc-gennpm 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) valuesdone
?SimpleCallback completion callback
Examples
bolt;
Returns Bolt
getRed
Retrieve Red value of the bolt.
Parameters
done
NumberGetterCallback completion callback
Examples
bolt;
Returns Bolt
setRed
Set Red value of the bolt.
Parameters
red
number Red value (0 to 255)done
?SimpleCallback completion callback
Examples
bolt;
Returns Bolt
getGreen
Retrieve Green value of the bolt.
Parameters
done
NumberGetterCallback completion callback
Examples
bolt;
Returns Bolt
setGreen
Set Green value of the bolt.
Parameters
green
number Green value (0 to 255)done
?SimpleCallback completion callback
Examples
bolt;
Returns Bolt
getBlue
Retrieve Blue value of the bolt.
Parameters
done
NumberGetterCallback completion callback
Examples
bolt;
Returns Bolt
setBlue
Set Blue value of the bolt.
Parameters
blue
number Blue value (0 to 255)done
?SimpleCallback completion callback
Examples
bolt;
Returns Bolt
getAlpha
Retrieve Alpha value of the bolt.
Parameters
done
NumberGetterCallback completion callback
Examples
bolt;
Returns Bolt
setAlpha
Set Alpha value of the bolt.
Parameters
alpha
number Alpha value (0 to 100)done
?SimpleCallback completion callback
Examples
bolt;
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;
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) valuesdone
?SimpleCallback completion callback
Examples
bolt;
Returns Bolt
getHue
Retrieve Hue value of the bolt.
Parameters
done
NumberGetterCallback completion callback
Examples
bolt;
Returns Bolt
setHue
Set Hue value of the bolt.
Parameters
hue
number Hue value (0 to 360)done
?SimpleCallback completion callback
Examples
bolt;
Returns Bolt
getSaturation
Retrieve Saturation value of the bolt.
Parameters
done
NumberGetterCallback completion callback
Examples
bolt;
Returns Bolt
setSaturation
Set Saturation value of the bolt.
Parameters
saturation
number Saturation value (0 to 100)done
?SimpleCallback completion callback
Examples
bolt;
Returns Bolt
getBrightness
Retrieve Brightness value of the bolt.
Parameters
done
NumberGetterCallback completion callback
Examples
bolt;
Returns Bolt
setBrightness
Set Brightness value of the bolt.
Parameters
brightness
number Brightness value (0 to 100)done
?SimpleCallback completion callback
Examples
bolt;
Returns Bolt
getState
Retrieve State value of the bolt.
Parameters
done
BooleanGetterCallback completion callback
Examples
bolt;
Returns Bolt
setState
Set State value of the bolt.
Parameters
state
boolean State valuedone
?SimpleCallback completion callback
Examples
bolt;
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 valuedone
?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 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
done
Function completion callbackdone
NumbersGetterCallback completion callback
Examples
bolt;
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;
get
Retrieve an bolt from internal registry.
Parameters
id
string bolt identifier
Examples
let bolt = Bolt;bolt;
Returns Bolt?
remove
Remove an bolt from internal registry.
Parameters
id
string bolt identifier
Examples
let bolt = Bolt;
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!