Integration of MiLight, LimitlessLED, Easybulb, etc (2 methods)

Hopefully this helps other users avoid the headaches I found while trying to integrate my Milights with Smartthings. In the following instructions substitute MiLight with Limitless LED, Easyblub, etc since as far as I’m aware they all work the same or just as a general purpose URL requester.

Here is the Android method:($3.90 for Google App)

Requirements:

-My MiLight app installed to SmartThings (code listed below and also hosted on BitBucket: https://bitbucket.org/BrianFreund/http-url-requester)
-The MiLight Controller (know the IP and Port it’s using)
-$3.90 for the App Store on Google
-An Android phone on the network capable of running the app “Automagic * Automation” & “UDP Sender” (Also need the IP address for this)

  1. Download and install an app called Automagic * Automation ($3.90) similar to Tasker ($2.99) however I was easily able to set up what I needed where Tasker I’m not sure is capable.

  2. Download and install an app called UDP Sender (Free)

  3. Create a “Flow” in Automagic that when an HTTP Request is made, triggers the UDP Sender app as a Plugin to send the HEX codes from http://www.limitlessled.com/dev/

  4. Create a SmartApp that, based on your preferences, will send the HTTP POST request to your Androids local IP, through the Automagic app which activates the UDP Sender, that controls the lights, all simply on your WiFi network!

  5. Repeat and rinse as necessary for whatever custom events/triggers you need

Here is a YouTube video I created demonstrating installation to integration: https://www.youtube.com/watch?v=kZm5q54WU6U

I want to call out Patrick Stuart (@pstuart) and Jason E (@jasone for their extraordinary help with their forum posting in aiding others with code. Definitely helped me get to where this is today as simple as it is.

Here is the Server method: (Free)

Requirements:

-My MiLight SmartThings app (code listed below and also hosted on BitBucket: https://bitbucket.org/BrianFreund/http-url-requester)
-The http-to-shell node server and associated files (hosted also on BitBucket: https://bitbucket.org/jschraub/http-to-shell
-Node version 6.9.2 or higher & NPM
-Linux/Mac/Windows machine, ideally “always-on” to run the http-to-shell server
-The MiLight Controller (again, need the IP it’s using)

  1. First ensure you have the required programs: NPM and Node version 6.9.2+ (for me installing node through this link worked a charm on my linux machine: “wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash”, afterwards I ran “nvm install node”, for windows I recommend using the installer located at: http://nodejs.org/ and run the same “npm install -ls” after completion)
  2. Then start by pulling the latest files from the repository at https://bitbucket.org/jschraub/http-to-shell. This will have the server.js file as well as the registered-commands.js file, essentially these two are what we’ll be configuring.
  3. Using NPM run “npm install -ls” while in the http-to-shell directory.
  4. Edit your url triggers and commands in the “registered-commands.js” file, examples are listed inside the file for you but here’s a quick breakdown,
    url: ‘/milight/1/on’ this is the url that should match from the MiLight app in SmartThings, anything really works so I usually just describe the location e.i. url: ‘/hallwayon’ (don’t forget your / )
    type: ‘milight’ default for using the native MiLight commands, the other choice is ‘shell’ but is only used for running external scripts, I now no longer need this functionality but definitely could be useful in the future or if you have other programming experience I’m sure this could trigger a multitude of things
    ip: ‘192.168.1.200’ this is your milight controller’s IP address
    zone: 1 your MiLight zone naturally
    bulbType: ‘rgbw’ depends on your bulb but could be either rgb, rgbw, or white
    color: ‘white’ this is default to turn your rgbw to white but if you define the color {0-255} it will turn that color after turning on, e.i. color: 176 would make it red, note the lack of quote when defining a number rather than ‘white’, also it’s unnecessary if not changing the color or leaving it as whatever it was last.
    brightness: 100 has a range of 0-100 and is also unnecessary if no adjustments are required
    off: false defaults to false so you can omit this entirely when turning on but needs to become true when turning off, the other optional options (color & brightness) become dismissed
  5. After you’ve configured everything (double and triple check your syntax, I lost count of the errors I had due to missing commas or forward-slash) then you should be able to run the server using “node server.js” and it will start with a default port of 9512 (configurable in the server.js file itself, though I’d be careful editing in that file)
  6. Send the url from the MiLight SmartThings app triggered by your switch and it should then log on the server that it recognizes the command and also what url command was received. Not to mention your bulb should change accordingly.

Acknowledgement shout out to Marcus Wittig from https://github.com/mwittig/node-milight-promise & https://jsfiddle.net/WittigMarcus/p0xw0jks/ for not only the MiLight Library API but also for a color selector that will show you the correct number that corresponds to the RGB for defining color in the registered-commands.js file.

/**
 *  HTTP Requests
 *
 *  Copyright 2015 Brian Freund (Credit goes to Patrick Stuart (@pstuart) and Jason E (jasone) for their code examples I copied plus of course the SmartThings Documentation which helped immensely)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
definition(
name: "HTTP URL Requester V2",
namespace: "brianfreund",
author: "Brian Freund",
description: "A SmartApp that when sends URL requests to a device that triggers when a switch is turned on or off. Designed for MiLights.",
category: "Convenience",
iconUrl: "http://apk-dl.com/detail/image/com.lierda.wifi-w250.png",
iconX2Url: "http://apk-dl.com/detail/image/com.lierda.wifi-w250.png",
iconX3Url: "http://apk-dl.com/detail/image/com.lierda.wifi-w250.png")

preferences {
section("Execute HTTP Request attached to switch") {
    input "theswitch", "capability.switch", required: true, title: "Which switch?"
}
section("Network Information"){
	input("DeviceIP", "string", title:"Device IP Address", description: "Please enter your URL Device's IP Address", defaultValue: "192.168.1.195" , required: true, displayDuringSetup: true)
			input("DevicePort", "string", title:"Device Port", description: "Please enter your Device's Port", defaultValue: 9512 , required: true, displayDuringSetup: true)
    input("PathOn", "string", title:"Path", description: "Enter a path for when the switch turns on", required: false, displayDuringSetup: true)
			input("PathOff", "string", title:"Path", description: "Enter a path for when the switch turns off", required: false, displayDuringSetup: true)
	}
}

def installed() {
	initialize()
}

def updated() {
	unsubscribe()
	initialize()
}

def initialize() {
	subscribe(theswitch, "switch", switchHandler)
}

def switchHandler(evt) {
	if (evt.value == "on") {
		onSwitches()
	} else if (evt.value == "off") {
		offSwitches()
	}
}

def onSwitches() {
def host = DeviceIP
def port = DevicePort
def hosthex = convertIPtoHex(DeviceIP)
def porthex = convertPortToHex(DevicePort)
def deviceNetworkId = "$hosthex:$porthex"
def ip = "$DeviceIP:$DevicePort"
sendHubCommand(new physicalgraph.device.HubAction("""POST $PathOn HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}"))
log.debug "$ip was sent $PathOn via $deviceNetworkId"
log.debug "host is $host, port is $port, hosthex is $hosthex, porthex is $porthex, deviceNetworkId is     $deviceNetworkId, ip is $ip"
}

def offSwitches() {
def host = DeviceIP
def port = DevicePort
def hosthex = convertIPtoHex(DeviceIP)
def porthex = convertPortToHex(DevicePort)
def deviceNetworkId = "$hosthex:$porthex"
def ip = "$DeviceIP:$DevicePort"
sendHubCommand(new physicalgraph.device.HubAction("""POST $PathOff HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}"))
log.debug "$ip was sent $PathOff via $deviceNetworkId"
log.debug "host is $host, port is $port, hosthex is $hosthex, porthex is $porthex, deviceNetworkId is     $deviceNetworkId, ip is $ip"
}

private String convertIPtoHex(host) { 
String hosthex = host.tokenize( '.' ).collect {  String.format( '%02x', it.toInteger() ) }.join()
log.debug "the returned host is $hosthex"
return hosthex
}

private String convertPortToHex(port) {
	String porthex = port.toString().format( '%04x', port.toInteger() )
log.debug "the returned port is $porthex"
return porthex
}
1 Like

This method may also work for local Lifx

1 Like

Have you considered using SharpTools for step 4? You can use SharpTools to subscribe to various Thing attributes which will create an event that you can react to in Tasker-compliant apps:

Edit: It looks like the Plugin feature is still listed under experimental support for Automagic. I would be interested in hearing if the SharpTools features work if you are interested in trying them out.

Unfortunately it’s not compatible with the Android version I have (2.3.5) so I’m having to resort to HTTP requests, thought I definitely did get excited when I found that as well initially.

@brianfreund Thanks for posting this - this looks to be exactly what I am after. As you say the existing integration is great but still in the development stage and I need something a bit more reliable as ST will be the only point of control for my bulbs. Can I just ask if this integration will show the current state of the bulb in ST, as long as the bulb is controlled via ST? Also have you had any success integrating this with SmartTiles?

If you could share your device type code that would be really great!

Thanks again,
dk

1 Like

You can also consider using a cheap-o tablet or one of those pseudo-burner cheap Android phones that someone mentioned in another thread.

You can use some of this magic in the background as a bridge but also have SmartTiles or something in the foreground as a control panel of sorts.

1 Like

So I apologize for the delay in this. I’ve recently dug myself a hole trying to create a more reliable physical bridge with the little dongle they provide but ended up paper-weighting it in the process so another one is on its way (more info found here on that https://servernetworktech.com/2014/09/limitlessled-wifi-bridge-4-0-conversion-raspberry-pi/#comment-25251 )

Prior to that I had developed a smartapp which should now be in the first post which is extremely basic and currently just does on/off functionality but I was hoping to develop it more in depth and eventually add greater user control and simple title switches as you suggested though I’m fairly new to this programming game and have no formal training in the subject so its mostly a hodge podge other code slapped together.

I’ll keep working on fully developing the app, since of course, for my own convenience it would a lot nicer than the crap code I’ve got going on right now. At least its something in the meantime though.

@brianfreund Hi Brian, Was just wondering how you were getting on with the latest version… would it be possible for you to share your device type code?
Thanks in advance,
dk

Hey @1bigwink, I actually just started a new job so I haven’t had much time due to travel to set anything up back to my original proof of concept pre-broken controller but as far as the device type code, it’s actually just a SmartApp code that I use and I’ve edited my original post to now include that, so just importing that to your own app collection should enable the same functionality that I was able to create provided you configure everything correctly. I can update again once I’ve gotten more time on my hands to integrate it all again.

Alright, after several months, I’ve finally created a step-by-step video on how this whole system works. @R2D2 this hopefully clears up any confusion you had and should get you on your way to a reliable method to integrate your easybulbs to smartthings. I’ve been using it reliably since my last post and have had no problems minus configuration issues (Android phone changing the IP address on me, set it to a static IP and now that’s fixed, routines not running due to my silly programming, also fixed.) But otherwise the functionality of the HTTP request to the android phone which triggers the Automagic app to send UDP commands through the MiLight Controller is sound and working great.

1 Like

Just got SmartTiles running and it works just as you would expect. The one issue I pointed out in the latest video I created is, if the light is altered by any other means (wifi remote, power loss, etc) then the “current state” will not sync. Simple way to restore it is to just toggle the switch on and off (or off then on depending on how it was left) and your “current state” should be correct. I imagine a simple rule or routine could accomplish this but I just manually sync it when it occurs (usually when I flip my breakers doing house maintenance and they automatically turn on with restored power).

Let me know if you need any more help!

1 Like

Hi Brian,

I’ve been looking for a way to control MiLights locally, and I think that this app is the easiest way to start. Here are the changes that I am planning to make using your app as a starting point:

  • Use a python script running on my media server in place of the smartphone
  • Integrate the “RGBW Light” device in place of the simple switch to gain dimming and color control interface in the app.
  • Use the python wifi LEDs package in place of UDP sender. Ideally, this will let me use the Smartthings app to directly send python commands within the HTTP request.

What are your thoughts? Have you made any progress on getting more advanced control of the lights since your last update?

1 Like

That would be great as I have made several failed attempts myself to integrate a few of my “always on” machines to control them however, my programming knowledge stops at what I’ve self-taught myself so far.

I’m sure with enough time and patience I could probably figure out a device type as you suggested however, for my purposes, really all I needed was an automated way to turn them off/on, a few colors maybe, and that was mostly it since I only have a few bulbs at the moment so at this point, I’m mostly finished with developing.

I did discover a script that ran on linux which I could successfully implement however couldn’t integrate but, with your knowledge you may be able to figure out a way I couldn’t. Here’s the link to the site I found and the scripts are easy to execute and the commands are essentially the same as the UDP sender. http://iqjar.com/jar/home-automation-using-the-raspberry-pi-to-control-the-lights-in-your-home-over-wi-fi/

I’ll make sure you’re aware, that I’ve had no formal training outside 1 Java class so my programming skills are rather lacking but I’d be happy to help test/collaborate with whatever you need.

Hi brianfreund

Have to tell, this code is great, you can add tasker using UDP and work 100% and tasker can read broadlink rm2, tasker is limit with alexa bridge on Android app, with this code Now I can use automagic with UDP u can conect with tasker and tasker read all broadlink codes easy, this code is unlimited, now I’m trying connection with my smart tv and cable box etc, this will be really fun to develop, ty great code,

Using for this config :
Milight wifi bridge rgbw led strip ( work all color perfect) dimmer dint test yet
SmartThings hub v2
Samsung Galaxy note n7000 with Android 6.0( force install)
Amazon alexa (set with smartthings hub skills)

1 Like

Is there a known windows application that will send UDP Hex upon receiving a HTTP request? I have a windows server that is always on. it would be nice to be able to skip the android phone and just work it through the computer.

Thanks,
Sean

Not to keep you in the dark for too long, but I am working with a friend of mine who programs for a living and we’re developing a node js server that will do exactly such a thing. I’ll have to test it out on windows as it’s being designed for Linux right now but either way, there are efforts right now to create such a thing. Stay tuned, I’ll post an update and walk-through here soon.

1 Like

I am not sure if you are aware or not, but Jared, another member who had released a popular milight ST controller application has moved to another home automation platform and his solution is no longer supported. So I’m really looking forward to what you come up with as I’m tired of having to use that lousy native milight application again to control my lights. Thanks for the hard work.

-Sean

Hey Sean, I was in a similar situation with Jared having stopped the service he supported and generously paid for, for so long (huge thanks to him). I had changed every light in my house to MiLights (more than 50 MR16 bulbs), so I was super disappointed to have lost ST integration.

That said, following Brian’s video instructions above, I was able to regain basic local ST control of my lights, relatively easily. I can now continue to switch my lights of and on via voice (Google Home), which is what I was using Jared’s solution for most of the time.

Eagerly awaiting to see what comes of this, and other initiatives for local MiLights control.

Cheers,

BT

1 Like

Hi Sean,

Yea, I was aware of Jared’s TCP solution which granted was more elegant in that it was two way communication as I understood it (SmartThings prerequesit for anything becoming “official”) however, what you’re experiencing is exactly what I was attempting to avoid. Having anything being routed outside of my network in general not to mention any potential lag, to me was unacceptable.

I’m still working with my friend (coincidentally also named Jared, no relation) and hopefully in a few days time will have something to present. As of right now there’s a crude version that hasn’t quite been field tested but is proven and we’re working to get it as simple as possible so hopefully it reduces any possible hiccups for anyone. To boil it down so you can get a preview of what’s to come, he’s built a node server I’ve installed on my linux machine (happens to be a Kodibuntu) and using a script I’ll link to once it’s all packaged together I found on another site that has basic milight functionality eliminating the need for an android.

Alright Lads and Lassies,

Saddle your horses because it’s about to get real! I have a cross platform solution that can be run independently and will integrate SmartThings with MiLights (Limitless LED, etc, etc).

It’s essentially a node server and my knowledge of it is fairly limited as I mentioned earlier, I collaborated with my friend - Jared Schraub, that did all the coding for the server itself (big shout out and thanks to him for his time spent and knowledge lent) however, I have enough of an understanding to hopefully step-by-step walk through installing everything. To keep it simple I’m going to append the instructions for the new method to my original post so that way everything is in one place and quick and easy to access.

Questions, comments, concerns, suggestions are all welcome on this thread and I’ll do my best to be prompt in responsiveness but if things get fairly technical regarding the server itself, fair warning that I may only be able to reply with a “I’ll have to ask Jared, or I could Google around for 10+hrs” but outside of that, once it’s running you should be set.

Some background for anyone that’s curious:
The node server’s original intent was to utilize the url trigger I’ve already created with my Milight SmartThings app and simply parse that into a shell command that would run a corresponding script I found online specifically for Linux however, in the process we discovered an API that basically combined everything we needed into one package that itself we used a node server so we would still have the shell command capability as well as it natively also does the MlLight commands all from the url request. So basically, install my MiLight SmartThings app, define the parameters, run the server and you can control all your lights on top of running whatever other scripts you want/desire.

Cheers!

2 Likes