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

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.

5 replies on “Full control of your LimitlessLED/Milight – v6- bulbs from Amazon Echo”

  1. Thanks for this Tutorial, but I get stuck with installing Node-Milight Promise.
    How can I install Node-Milight Promise?

  2. @Christof First you need to install Nodejs. Installation instructions differ between Windows/Linux/Mac but they’re pretty straightforward.
    Once Node is installed – create folder for your code an inside that folder run command

    npm install node-milight-promise

    This will do actual install of Node-Milight Promise. After that you can create led.js in the same folder as described above and it’s ready to go.

  3. Just leaving a note for any others that may be having trouble getting this up and going – if you have the RGBW bulbs with no adjustment between warm white and cool white, you’ll need to change the commands used from (commands.fullColor.on) to (commands.rgbw.on). This tripped me up for a bit, but it makes sense since I also had to adjust the remote being used in the Limitless app before I had proper control.

    As far as installing nodejs, I found the instructions here (http://thisdavej.com/beginners-guide-to-installing-node-js-on-a-raspberry-pi/)to be very thorough, though if your pi is already set up you can skip the bulk of the article.

    Hope this helps!

  4. Thanks for both your Mi-Light/HA-Bridge articles! Got this working with my 22 v6 Mi-Lights at home via two WiFi controllers. Node-Milight-Promise is a nice find too and got this all up and running on both a Windows 10 box and now a Rapsberry Pi running Jessie. Seems to be some problems getting habridge to link with Google Home, but it works fine via Amazon Echo. Thanks again your articles really helped me get up and running here!

  5. I believe Google Home works only if HABridge is running on port 80. Try changing port and use Home again.

Leave a Reply

Your email address will not be published. Required fields are marked *