• Home
  • About
  • Resume

Full control of your LimitlessLED/Milight – v6- bulbs from Amazon Echo

By , 02/24/2017 9:42 PM

A while ago I blogged about controlling you Milight smart bulbs from Amazon Echo. This was done by sending raw UDP packets directly to Milight bridge. Since a packet consisted only of a few bytes – this was manageable.

Then we got v6 of Milight bulbs. They’re vastly superior to previous version – besides brightness and color you can set warmth and saturation among other things. But with new features came increase complexity of commands. UDP packets now consist of huge number of bytes and you cannot simple send packet and forget it, response matters too.

HA-Bridge, which is used to emulate Phillips Hue bulbs so Echo can detect the devices, is incapable of such commands. Thankfully it can run external scripts.

Enter Node-Milight-Promise. This is a node module that creates a pretty cool wrapper around raw Milight commands. For example to turn on Zone 1 you can simple call commands.fullColor.on(1); or to set brightness of Zone 3 you can call commands.fullColor.brightness(3, 100);. With this in mind we can create a universal controlling script and call it from HA-Bridge passing zone, brightness etc. as parameters. Here is an example of such script (led.js):

var Milight = require('node-milight-promise').MilightController;
var commands = require('node-milight-promise').commandsV6;

var light = new Milight({
    ip: "192.168.1.24",
    type: 'v6'
}),

zone = process.argv[2],
action = process.argv[3];

switch (action) {

   case "on":
      light.sendCommands(commands.fullColor.on(zone), commands.fullColor.whiteMode(zone), commands.fullColor.brightness(zone, 100));	
      break;

   case "off":
      light.sendCommands(commands.fullColor.off(zone));	
      break;

   case "dim":
   case "bright":
   case "brighten":
      light.sendCommands(commands.fullColor.brightness(zone, process.argv[4]));
      break;

}

light.close().then(function () {
  console.log("All command have been executed - closing Milight");
});
console.log("Invocation of asynchronous Milight commands done");

It creates a Milight object with bridge IP address as a parameter. The cool thing about this module – it supports previous version of Milight as well – you just have to specify type parameter. Here’re couple examples of calling the script:

nodejs led.js 2 on — will turn on Zone 2
nodejs led.js 3 dim 50 — will dim Zone 3 to 50%

The only thing left now is add these commands to HA-Bridge:

HA-Bridge configuration

And these commands will be identical for other zones, just the parameter for zone number will change.

Once devices are set up tell Alexa to discover devices. Once she is done, you can call devices by the names you gave them. “Alexa turn on kitchen light”, “Alexa dim bedroom light to 20%” etc.

Leave a Reply

Panorama Theme by Themocracy