LiFX new SDK


(Barry Murphy) #1

Hey guys,

Dont know how new the LiFX SDK is; they’re in IFTTT.com now too.
See http://api.developer.lifx.com/

You login to their cloud and generate a token, then every time you want to talk to the REST API, you just supply the token and it provides details for your lights, like listing lights, turning them on or off, color, fade, breath effect, etc.

I’ve just ordered my first ST Hub so am waiting for it to arrive but I’m amazed not many; if any people using Lifx.
I know they have been really slow to develop an API that was reachable outside of the home network, but it seems its finally here and works!

How easy would it be to put this into ST?

Listing lights and their current state
curl -H “Authorization: YOUR_APP_TOKEN” “https://api.lifx.com/v1beta1/lights/all

Turn all lights on
curl -H “Authorization: Bearer YOUR_APP_TOKEN” -X PUT -d “state=on” “https://api.lifx.com/v1beta1/lights/all/power

Set all light purple
curl -H “Authorization: Bearer YOUR_APP_TOKEN” -X PUT -d “color=purple” “https://api.lifx.com/v1beta1/lights/all/color

Any help would be appreciated :smile:
Thanks
Barry


(sidjohn1) #2

Check out Nicolas Cerveaux’s (@zzarbi) work on Github. I’ve been using it for a while.

Smartapp: https://github.com/zzarbi/smartthings/blob/master/app/lifx/lifx-connect2.groovy

Device type: https://github.com/zzarbi/smartthings/blob/master/device/lifx/lifx-bulb-2.groovy


(Barry Murphy) #3

Thanks for this, very helpful indeed!

I’m trying to add the device in the web dev area and its asking for some
Device Network Id & Type

Is there any quick how to on how to add the groovy codes to the web sdk?


(sidjohn1) #4

There is no need to manually add the devices, use the smart app to connect to your lifx account. The smart app will create devices based on what it finds in your account.


(Barry Murphy) #5

Thanks for this, first time doing it and managed to work it out; ST is such an awesome design!


(Anthony S.) #6

I’m not sure if something changed on the platform. but i can not control my LiFx bulbs any more.
I have had no issues with these but now they won’t respond at all.
I am getting the following in the logs:

___exception: javax.net.ssl.SSLException: hostname in certificate didn't match: <api.lifx.com> != <*.lifx.co> OR <*.lifx.co> OR <lifx.co>

(Alex Christensen) #7

Mine stopped working today as well. I’ve only had it going since Sunday but it was fine until sometime today.


(Anthony S.) #8

thanks for confirming…
It’s alway’s something I guess.
I just tested the Lifx api directly and it’s working as it should. I’m wondering if this is related to behind the scenes security updates.


(Barry Murphy) #9

Just came home to a dark house :frowning:
Sad panda :cold_sweat:


(sidjohn1) #10

Same over here, i even deleted and readdded the lights, no love. I wish there was a way to control them w/o the cloud.


(Barry Murphy) #11

Think i found the issue, they renewed their SSL certificate today, the new certificate is allocated to *.lifx.com
Perhaps ST doesnt like a wildcard cert? Not sure if the previous cert was api.lifx.com or *.lifx.com

If it was a simple renewal, perhaps its just a timezone issue and the new cert isnt active yet


(Barry Murphy) #12

Perhaps @zzarbi may know how to make the ST app not worry about the SSL hostname?

___exception: javax.net.ssl.SSLException: hostname in certificate didn't match: <api.lifx.com> != <*.lifx.co> OR <*.lifx.co> OR <lifx.co>

(Nicolas) #13

I updated the code about 3 hours ago. I change the URL to lifx.co instead of lifx.com
I don’t know why i see the correct certificate but smarthings doesn’t… it might be timezone issue.

@icepicknz In PHP i know how to bypass ssl verification, in groovy however I didn’t find a way


(Barry Murphy) #14

Tried that it didnt work, also copied all the code and replaced the code I had and saved and published; no change?
Is yours now working?


(sidjohn1) #15

This seams similar to the netamo issue that @Dianoga fixed. You might to PM him to see how he fixed it.


(Nicolas) #16

Mine is working, I’m not sure what’s happening here.


(Nicolas) #17

Oh and I started integration of Groups:

It’s mostly working and kinda acting as “one” bulb so everything you can do with one bulb you can do with one group… However the syncing between group and bulb might be delayed a bit. What this mean is, if you turn a group on, it will turn the lights on however their respective device on Smartthings won’t be on until, the poll request get call which happen every 5 minutes. The syncing is a bit more complicated…

If you guys have some feedback that would be great also I was thinking of integrating scenes but I’m not sure how yet.


(Barry Murphy) #18

Excellent @zzarbi groups is something i was keen on; have you had any luck talking to the lights direct through the hub rather than cloud? i.e. LAN


(Barry Murphy) #19

I been tweeting to lifx and smartthings. Lifx made a change not supported by smartthings. They have reverted the certificate back to cloud flare so things may break again @zzarbi


(Nicolas) #20

Oh yeah it was an outage on their part http://status.lifx.com they seem to have fixed it.
@icepicknz There is no way to control them via the LAN, the protocol used by LIFX is a bit complicated and the HUB can’t handle it… At least not this version of the hub.


LIFX and Works with Nest