Hi All,
I have used this forum quite a bit and wanted to contribute back. After many painful hours and weeks trying to setup my MiLights (LimitlessLED, EasyBulb, etc) to work with Smart Things reliably I finally landed on a formula that works.
What I was trying to do
- Google Home control my MiLights (v6 hub)
- SmartThings to build automation on my MiLights (e.g. Motion sensor to turn lights on, routines)
- Use most of the MiLight features (e.g. Night Mode)
- Not have something that left my home network (e.g. wanted it to be fast) and reliable (I tried a lot on here that would crash)
What you need
- MiLights + v6 Hub
- SmartThings Hub
- System capable of running Node script and Ha-Bridge (rPi, Windows, Linux, Mac all support) running 24/7, most people in this forum seem to have a computer running 24/7
Overview
- Google Home talks to Smart Things (Note: Google Home can talk direct to Smart Things, however it means you need to run more items to keep HA-Bridge and Smart Things in sync)
- Smart Things sends commands to Ha-Bridge (on, off, brightness - color is not supported in this without using silly names)
- Ha-Bridge executes a local node script
- Node script (not written by me - used by many others already and reliably: https://github.com/mwittig/node-milight-promise) sends a signal to the v6 Hub to control lights
Software Setup
- Install HA-Bridge on your preferred device (https://github.com/bwssytems/ha-bridge) - Lots of people have created videos on how to install / update HA-Bridge
- Install NodeJS (https://nodejs.org/en/) - Again, many instructional videos already on how to do this
- Make sure you installed them on the same server (for ease of use)
Set-up, test and integrate Node script with HA-Bridge
I followed these instructions: http://codecorner.galanter.net/2017/02/24/full-control-of-your-limitless-ledmilight-v6-bulbs-from-amazon-echo/
I wrote my own code at this step, you can also look at heaps of examples written by the node-milight-promise author on the Git Readme page(https://github.com/mwittig/node-milight-promise). My version added more commands to give me more flexibility within HA-Bridge, including controlling colour warmth (I found this really useful as it would automatically set the bulbs to my preferred setting - incase we’d changed colour or otherwise accidentally). My code repeats itself a little as I was testing different ways to operate it within HA-Bridge (I left this in so people could see different options).
var Milight = require('./src/index').MilightController;
var commands = require('./src/index').commandsV6;
var light = new Milight({
ip: "192.168.x.xxx",
type: 'v6'
}),
zone = process.argv[2],
action = process.argv[3];
white = process.argv[4];
bright = process.argv[5];
switch (action) {
case "on":
light.sendCommands(commands.fullColor.on(zone), commands.fullColor.whiteTemperature(zone, white), commands.fullColor.brightness(zone, 100));
break;
case "allon":
light.sendCommands(commands.fullColor.on(zone), commands.fullColor.brightness(zone, 100));
break;
case "off":
light.sendCommands(commands.fullColor.off(zone));
break;
case "dim":
light.sendCommands(commands.fullColor.on(zone), commands.fullColor.whiteTemperature(zone, white), commands.fullColor.brightness(zone, bright));
break;
case "alldim":
light.sendCommands(commands.fullColor.on(zone), commands.fullColor.brightness(zone, bright));
break;
case "night":
light.sendCommands(commands.fullColor.nightMode(zone));
break;
}
light.close().then(function () {
console.log("All command have been executed - closing Milight");
});
console.log("Invocation of asynchronous Milight commands done");
My HA-Bridge commands:
- Turn on a light as warm white (e.g. for living room):
node "[full-path-to-code]\led.js" 1 on 10
- Light 1, turn on, to a warm white colour - Turn on a light as a cool white (e.g. for bathrooms):
node "[full-path-to-code]\led.js" 1 on 100
- Turn off:
node "node [full-path-to-code]\led.js" 1 off
- Dim warm white lights:
"node [full-path-to-code]\led.js" 1 dim 10 ${intensity.percent}
- Set all MiLights into night mode:
"node "[full-path-to-code]\led.js" 0 night
Once you’ve tested it all works via the HA-Bridge interface - just one last step.
HA-Bridge -> SmartThings
- Open SmartThings app, Add a Thing, all the lights you just created will show-up in here
Controlling it via Google Home
- Link SmartThings and Google Home, it will automatically populate all your lights. You will be able to control these lights throuugh the standard commands. E.g. “Hey Google, turn on the [name of light]”, “Hey Google, set the [name of light] to 50%”.
- To control items like “Night Mode”, I added a light called “Night” in HA-Bridge, then I say “Hey Google, turn on Night” - in the example above, it will put all lights into the Night Mode setting
- This will not control color
Hope this helps others trying to do the same, I strung together a few examples and tweaked some code along the way - big thanks to:
- mwittig for the awesome and highly reliable node script: https://github.com/mwittig/node-milight-promise
- yuriy for the original code that got me going: http://codecorner.galanter.net/2017/02/24/full-control-of-your-limitless-ledmilight-v6-bulbs-from-amazon-echo/