LED BLE Library
The ble_led (About Modules) library turns your Espruino device into a Bluetooth LED device compatible with the Python led-ble library which means your device can appear in Home Assistant with the LED BLE integration.
Once configured, a device running this library will appear in http://homeassistant/config/integrations/dashboard
where it can be used alongside all your other devices.
💡This code can be uploaded in a few clicks with the Espruino App loader
Usage
Simply instantiate as follows:
require("ble_led").setup(function(state) {
if (state.on) {
// state.r/g/b arr in the range 0..255
LED1.pwm(state.r/256);
LED2.pwm(state.g/256);
LED3.pwm(state.b/256);
} else {
digitalWrite([LED1,LED2,LED3],0);
}
});
Every time the light state changes, the callback will be called with an updated state
variable, which is of the form:
{
on:false,
r:255,
g:255,
b:255,
w:255,
version:0
}
In the example above, we assume your device has red, green and blue LEDs as LED1/2/3
, but you could wire up external LEDs, or use the state.on
value to trigger something other than a light.
Using
This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.