Page 1 of 1
RaZberry + Lifx?
Posted: 09 Mar 2014 21:06
by janeja
Hi.
Is it possible to use the following API:
https://www.npmjs.org/package/lifx with RaZberry?
It would be awesome to use the Lifx bulbs together with Z-way

Re: RaZberry + Lifx?
Posted: 10 Mar 2014 00:39
by PoltoS
Only if you can do it with HTTP requests. But anyway the npm will not run on RaZberry as is - you will need to rewrite the code a bit (not really much)
Re: RaZberry + Lifx?
Posted: 12 Mar 2014 23:36
by janeja
How can I send a request from Z-way? I'm trying with xmlhttp, but I cannot create a new xmlhttp object.
Re: RaZberry + Lifx?
Posted: 30 Mar 2014 14:41
by PoltoS
There is http.request({url: <URL>, method: "POST" | "GET", ...})
Re: RaZberry + Lifx?
Posted: 26 Nov 2015 17:20
by Sparkacus
I don't suppose someone could explain how you would go about setting up the http request? - I'm new to programming and z-way
I would use the HTTP request app in z-way, but I need to add an authentication header.
Basically I want to POST to:
https://api.lifx.com/v1/lights/SELECTOR/toggle
with the header:
"Authorization: Bearer TOKENID"
I did get this to work using xmlhttp in a browser console and thought I could just port that into the Javascript Code app in z-way, but that fails as I believe the xmlhttp object (maybe I said that wrong) is not available. I believe that object is built into my browser, which is why that works.
I tried to install xmlhttp via npm, but that didn't help.
I then tried the following code, but it doesn't work:
var options = {
url: 'api.lifx.com/v1/lights/SELECTOR/toggle,
port: 443,
method: 'POST',
headers: {
'Authorization': 'Bearer TOKENID'
}
};
http.request(options);
Any suggestions?
Re: RaZberry + Lifx?
Posted: 26 Nov 2015 17:53
by Sparkacus
OK I got it to work with:
var options = {
url: '
https://api.lifx.com/v1/lights/SELECTOR/toggle',
method: 'POST',
headers: {
'Authorization': 'Bearer TOKENID'
}
};
http.request(options);
Is the above bad coding? i.e am I supposed to close the request some how?
Re: RaZberry + Lifx?
Posted: 29 Nov 2015 00:55
by PoltoS
no, it will close itself.
Re: RaZberry + Lifx?
Posted: 29 Nov 2015 19:05
by Sparkacus
Ok great, thanks for that
Although this is off topic, I also have a Particle Photon which controls my driveway lights. The problem I had when using the JS code above was that no other z-wave device would work until the request had returned something. My driveway lights dance for 10 seconds, hence my issue.
I found out that I could use command line via javascript using JS system(), so I ended up using curl as I knew I could use the '--max-time' option to force curl into closing the connection after x seconds:
system('curl --max-time 1
https://api.particle.io/v1/devices/DEVICECODE/FUNCTION -d arg=\'ARGUMENT\' -d access_token="ACCESS_TOKEN"');
I could change the code on my Photon to return a value immediately before executing a task (assuming I have the skillz), but I was too lazy to look

Re: RaZberry + Lifx?
Posted: 29 Nov 2015 21:01
by pz1
@spartacus
Don't go off topic!! Start a new thread for your new problem.