Controlling Bluetooth Lights with Puck.js

This video shows you how to control most types of Bluetooth lightbulb using Puck.js.

The actual code used is:

function setLight(isOn) {
  var gatt;
  NRF.connect("98:7b:f3:61:1c:22").then(function(g) {
    //         ^^^^^^^^^^^^^^^^^  your light's address here
    gatt = g;
    return gatt.getPrimaryService("33160fb9-5b27-4e70-b0f8-ff411e3ae078");
  }).then(function(service) {
    return service.getCharacteristic("217887f8-0af2-4002-9c05-24c9ecf71600");
  }).then(function(characteristic) {
    return characteristic.writeValue(isOn ? 1 : 0);
  }).then(function() {
    gatt.disconnect();
    console.log("Done!");
  });
}

var on = false;
setWatch(function() {
  on = !on;
  setLight(on);
}, BTN, { repeat:true, edge:"rising", debounce:50 });

But you'll have to change the address to that of your lightbulb!

This code will work with Awox Smartlight C9 and W13 bulbs. For other bulbs you may need to use the steps shown in the video to work out which characteristics were used.

Extras

For the Awox Smartlight W13 you can also change:

Buying

You can buy the lights I used here from eBay:

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.