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

By , February 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.

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

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

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

  8. 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?

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

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

  11. 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 😉

  12. Petter Miltén says:

    Thanks a lot! Have tried all different kinds of fixes for this, none worked so far and then I stumbled onto this late last night. Works like a charm!
    Can add that if you have all white (WW/CW) lights there are different commands for them aswell, change fullColor to white as described for rgbw above.

  13. i0i0 says:

    Hi, I was wondering if I could seek some help with the node-milight-promise.

    I have followed the guide and managed to install NodeJS & HA-Bridge but encountered problem with node-milight-promise. Followings are steps I took;

    0. Setting up rasberry pie 3B, installed NodeJS & HA-Bridge.
    “node -v” returns v9.4.0.
    can access HA-Bridge Web Interface.

    1. Installed node-milight-promise within “habridge” folder using “npm install node-milight-promise”, which created “/habridge/node_modules/node-milight-promise”.

    2. Copied Yuriy’s script “/habridge/led.js” for testing purposes.
    only changing ip to Wifi Bridge ip address.

    3. Testing “nodejs led.js 1 off” within “habridge” folder; Zone 1 off.

    4. Received msg;
    “Invocation of asynchronous Milight commands done”
    “All command have been executed – closing Milight”

    5. No response from LEDs.

    *** I can control LEDs via app. I can scan WiFi Bridge via LimitlessLED admin tool for windows.
    *** LimitlessLED Wifi Bridge, model no. iBox2 (the one w/ black strip, I am guessing this is V6?)
    *** This is best I can provide in my knowledge and skills, please let me know if there is a log I could access & provide?

    The Question is what am I doing wrong, and is there any way I can test if Wifi Bridge itself or node-milight-promise is working properly? I am not sure where it went wrong.

    Is node-milihgt-promise sending commands properly?
    Did I make mistake invoking commands?
    Did I make mistake installing node-milight-promise?

    Any help would be greatly appreciated~!

  14. Milight v6 says:

    Hi, wondering if you could help me out as well.

    Did the following:

    Installed nodejs (running v4.8.2)
    Installed npm
    Installed node-milight-promise in home/pi/habridge/nano/

    created led.js in /home/pi/habridge/nano

    after invoking cmd nodejs /home/pi/habridge/nano/led.js 1 off

    i receive the message from the terminal that everything is ok, but lights doesnt seem to respond.

    I have put in the IP address of the v6 bridge.
    I also tried to change the last ip digits to .255

    Remark: i cant seem to find the .milightcontroller or commandsv6 file in the node-milight-promise directory.

    Hoping you can help out

    BR Rob

  15. Milight v6 says:

    small update

    running nodejs v9.8.0
    and npm 5.6.0

    i have located my wifi box IP adress with the help of the milight admin tool. I used this ip in the script above.

    remark: i have found the milight and commandsV6.js files . I was wondering if i should update the resource link for MiLightcontroller and CommandsV6

    Thanks in advance

  16. Milight V6 says:

    Hi all,

    I have managed to get it working.
    My mistakes:

    Did not used the right nodejs version
    Did not used the right npm version

    Changed fullcolor to rgbw (although i use rgbw lamps)
    Changed zone behind the control instead of only parsing it as argument in the HA bridge

    example: (commands.fullColor.on(1)

    instead of (commands.fullColor.on(zone)

  17. Sheriffdude says:

    Hi guys must give this a go but for now I have ha bridge turning of and on my lights .but before I try this .I can’t get my echo dot 2 to find ha bridge tried loads of things but it will not find it’s.on windows 10 ..ha bridge 5.2.1 any help would be great thanks

  18. Yuriy says:

    Guys, sorry I was unable to answer to all questions, been a busy year, but hopefully mutual comments have been helpful.

  19. JanOh says:

    Is there a way to control the color aswell?
    Everything is working but the color ?

    New version of HAbridge seems to support colors. Can someone post a screenshot of configuration how i get it to work.

    Many thanks in advance.

    Jan

Leave a Reply

Panorama Theme by Themocracy

Bitnami