• 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.

12 Responses to “Full control of your LimitlessLED/Milight – v6- bulbs from Amazon Echo”

  1. Christof says:

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

  2. Yuriy says:

    @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. Aaron says:

    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. Anthony Hicks says:

    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. Yuriy says:

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

  6. Ray says:

    Google home has apparently changes and only supports the hue protocol via the cloud option, or at least so i’ve read. So no local google home to ha bridge support anymore.

    You might want to check that though

  7. Thijs Bink says:

    Hmmm, after buying an v2 wifi controller if found this article :(. The thing is I can’t get both things to work. the previous method seems irresponsive. this is my code:
    udp://192.168.178.20:8899/0x450055 (this is the on-command). I’ve checked and I know pretty sure that …178.20 is my wifi box v2.

    The problem with the new method is the installing of node-milight-promise. I’m very unfamilliar with the cmd and most of it is literally copy and paste for me, the question is can I do it on a windows 10 pc or do I need a Rpi (which I have)?

    Any response is VERY welcome!!

    Thijs

  8. Thijs Bink says:

    wait I might have just figured my first problem out myself. I tested the limetlessLED wifi bridge and it suddenly worked. (because my lamps are now connected to the wifi box). So I pressed get IP and it turns out that my wifi box probably is located on the 178.33, which I didn’t know.
    That’s probably my problem, gonna try and fix it now 🙂

    Thijs

  9. Thijs Bink says:

    Update:

    The ip-address is correct (the .33) however it still doesn’t work, my new code is:

    udp://192.168.178.33:8899/0x450055 (for “on”)

    No response however,

    is there something i’m doing wrong?

  10. Thijs says:

    Allright I sort of get it now. I’ve downloaded node.js (checked the version with the cmd line “node -v”, its 7.10.0. So that’s covered, then I did the npm install in my folder located at /home/pi/node (i called the map node), and then I created a new file called led.js and copied your script to it. Then I changed the ipadress and I made the connection with habridge like so:

    type: execute command/script/programm
    target item: node.js /home/pi/node/led.js 1 on (as my lamps are located in zone one)

    Did the same thing for the off statement, but then put off instead of on.

    Then I get this error message:

    Request Error, Pleae look in your habridge log: error {“type”:6,”address”:”/lights/4″,”description”:”Error on calling out to device”,”parameter”:”/lights/4state”}

    I called the device “lights” in my HA-bridge and the ID is four, but I haven’t come any further with my troubleshooting.

    Can anybody tell me what I’m doing wrong? I really want this to work 🙂

    Kind Regards,

    Thijs

  11. Bob says:

    Hey guys, I believe I did everything what’s posted here, but i still get an error message.

    Can I get a little more explanation on what to do exactly? Especially with integrating the node.js scripts with the Ha-bridge. My Ha-bridge doesn’t really know what to execute I believe.

    Kind regards,

    Bob

  12. Norbert says:

    Thank you very much for your describtion, I was able to install everything on my raspi, which I have running anyway with pi-hole.
    Also thanks for the advices from Aaron, because I also had to change the commands to “commands.rgbw.on”. Additionally I’m now able to even switch on different colors with Alexa, thats magic 😉

Leave a Reply

Panorama Theme by Themocracy