eliotstocker / Light-Controller

To Control lights from companys such as limitless LED etc
http://eliotstocker.github.io/Light-Controller/
62 stars 24 forks source link

Non-local control of lights #7

Open dudeofawesome opened 9 years ago

dudeofawesome commented 9 years ago

One way to go about this would be to retrieve the user's external IP address when they attempt to control the light, and store that address. Then, when the user is not connected to their home wifi network, we could switch the app to sending the UDP packets to the external IP address, assuming the user has forwarded the correct port to the bridge.

zenitraM commented 9 years ago

Hey, just for anyone who got here looking (as me) for documentation on this "cloud protocol": I have a Milight with its WiFi bridge from a random Aliexpress seller. I tried using the LimitlessLED Windows control app (works fine on Wine) at http://www.limitlessled.com/dev/

It has some settings to get and set the Cloud API port and host to use:

Someone mentioned earlier the EasyBulb API, at http://easybulb.com/api/. Well, the EasyBulbs seem to be plain Milights, so I figured out you can just point the bridge to port 38889 on api.easybulb.com and then use their HTTP API to remotely interact with your bulbs with your own Mac addresses.

It seems that there is no UPNP or any other trickery on the bridge - just a plain, long-living TCP connection. The "Cloud API" does the rest.

Of course I don't like the idea of using any manufacturer/distributor hosted API - the way should be either finding documentation or reversing the TCP protocol and then creating a proxy which acts as a middleman - I might do this at some point.

gdbgeek commented 9 years ago

zenitraM, that is very interesting. I assume your "WiFi bridge from a random Aliexpress seller" must be the V5 bridge as I dont believe the old V4 bridges support those command sets.

zenitraM commented 9 years ago

@gdbgeek Well, I got it back in April, and there are no markings on it telling the version, it's this one: http://aliexpress.com/item/2-4G-MI-Light-Wireless-WIFI-RGB-color-Strip-bulb-lamp-internet-Remote-Controller-for-Iphone/2032002345.html?isOrig=true#extend so not sure if it's a 5.0 or not as the LimitlessLED docs say it was released on September, maybe it's even a 4.0.

Just figured out the "protocol", it's not even a real protocol: the bridge opens a TCP socket to the "cloud server" and sends its MAC as raw text, and periodically sends Li_Link\n.

The only thing the server ever sends are the same hex commands that are sent over UDP, when they are sent. So this makes it quite easy to create an "online hub".

gdbgeek commented 9 years ago

Awesome, I've got a spare hub so I might try this out, I thought the new commands required a V5 wifi bridge but perhaps I'm mistaken.

gdbgeek commented 9 years ago

zenitraM, I can also set the cloud server on my V4 bridge. The easybulb API is really easy to use. Thanks for sharing.

LimitlessLED commented 9 years ago

Yes, all bridges versions support those command sets in some capacity or another.

Regards,

Hamish.

-LimitlessLED

From: gdbgeek [mailto:notifications@github.com] Sent: Friday, 30 October 2015 9:50 a.m. To: eliotstocker/Light-Controller Cc: LimitlessLED Subject: Re: [Light-Controller] Non-local control of lights (#7)

zenitraM, that is very interesting. I assume your "WiFi bridge from a random Aliexpress seller" must be the V5 bridge as I dont believe the old V4 bridges support those command sets.

— Reply to this email directly or view it on GitHub https://github.com/eliotstocker/Light-Controller/issues/7#issuecomment-152317788 . https://github.com/notifications/beacon/AJ6MMIyte-ZSsQZ54Ts5smJ7T5EI2Bwcks5pAn4QgaJpZM4C2qn1.gif

jjensn commented 8 years ago

@gdbgeek @zenitraM are you two having any luck with either of the POST commands (colour/brightness) ? I am getting error 500 for color and invalid JSON for brightness.

gdbgeek commented 8 years ago

@cloudsyjared I haven't tried any of the colour/brightness commands. What are you using to send the commands?

gdbgeek commented 8 years ago

Actually @cloudsyjared I just tried and also receive a Server Error (500)

jjensn commented 8 years ago

@gdbgeek Firefox plugin

gdbgeek commented 8 years ago

@cloudsyjared with the brightness I do get this message

{"success": false, "error": "Device not found"}

Which is probably correct since my bridge isn't on right now.

gdbgeek commented 8 years ago

Slightly off topic. @cloudsyjared Im having a decent play with the API now as Im building an intermediate server in order to send commands via IFTTT. I've noticed that I can turn all of my white bulbs on/off but it doesnt work with a specific group. The Easybulb API tells me its successful but no lights are turned on.

jjensn commented 8 years ago

@gdbgeek yeah I gave up on the easybulb route and wrote my own this weekend

gdbgeek commented 8 years ago

@cloudsyjared your own API? I'm contemplating the same now.

jjensn commented 8 years ago

@gdbgeek yep wasn't too bad

gdbgeek commented 8 years ago

@zenitraM do you recall in your tests if the MAC address you see is the same MAC as you see in the official app? I'm seeing a similar MAC but the last octet is incremented by 1 (e.g. if the bridge ends with 9E I'm seeing 9F being sent to the server). I've tested 4 bridges and they all do the same thing.

eliotstocker commented 8 years ago

I'm thinking we should start a wiki here to keep all of this info in a nice neat order

Zulex commented 8 years ago

Is this feature going to be implemented in the app since some of you guys figured out how to control it from other networks. The app from : http://mi-light.com ( not the official milight manufacturer ) is able to do it without any port forwarding or changing settings. Even using colors, someone figured out how? I got the same server error.

jjensn commented 8 years ago

I have written an api + service for this that I plan on announcing soon. You can check for updates on the mithings project under my github page

Sent from my iPhone

On Aug 19, 2016, at 7:07 AM, Zulex notifications@github.com wrote:

Is this feature going to be implemented in the app since some of you guys figured out how to control it from other networks. The app from : http://mi-light.com ( not the official milight manufacturer ) is able to do it without any port forwarding or changing settings. Even using colors, someone figured out how? I got the same server error.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

mrwhale commented 8 years ago

Hey guys, I think once we have launched milestone 1.8 this will be the first feature to be done for the next milestone. Once I've finished the pebble feature, I might start hacking something together to get a working prototype of this feature, see how easy it's going to be.

Nice stuff @cloudsyjared will definitely keep an eye on that :)

Zulex commented 8 years ago

@cloudsyjared Cool project, will it only work with smartthings or are you planning to make apis/libraries?

I had a look in the API of easybulb, won't that be enough to contol it by network? The server is given and authentication works with mac adresses, so we only need automatic detection of these adresses. The API can be found here : http://easybulb.com/api/

jjensn commented 8 years ago

It's an exposed web api, so anyone can use it as long as they write the app to call it. Stay tuned

Sent from my iPhone

On Aug 21, 2016, at 2:49 PM, Zulex notifications@github.com wrote:

@cloudsyjared Cool project, will it only work with smartthings or are you planning make apis/libraries?

I had a look in the API of easybulb, won't that be enough to contol it by network? The server is given and authentication works with mac adresses, so we only need automatic detection of these adresses. The API can be found here : http://easybulb.com/api/

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.