Hi all,
I have been waiting for some good lifx plugins to come out and from what I hear a few users are currently working on some, but for the meantime I wanted to be able to control some of the lights in my room so I made this small little script to help with it.
It only allows one set of lights to be controlled at the moment but im sure with modification you could use it for many more.
Lifx.js
You need to make a virtual device that has a on button off button and a slider if you want color temperaturecontrol, you then use events to call the script and control the lights, its not a great way of doing it but it something for the meantime while we wait for a proper plugin.


I have been waiting for some good lifx plugins to come out and from what I hear a few users are currently working on some, but for the meantime I wanted to be able to control some of the lights in my room so I made this small little script to help with it.
It only allows one set of lights to be controlled at the moment but im sure with modification you could use it for many more.
Lifx.js
Code:
function turnOn(){ var url = "https://api.lifx.com/v1/lights/group:GROUPNAME/state"; var dataRequest = '{"power" : "on", "brightness" : "1"}'; var client = new ActiveXObject("Microsoft.XMLHTTP"); client.open("PUT", url, true); client.setRequestHeader("Authorization", "Bearer <API KEY>"); client.send(dataRequest); } function turnOff(){ var url = "https://api.lifx.com/v1/lights/group:<GROUP NAME>/state"; var dataRequest = '{"power" : "off", "brightness" : "0"}'; var client = new ActiveXObject("Microsoft.XMLHTTP"); client.open("PUT", url, true); client.setRequestHeader("Authorization", "Bearer <API KEY>"); client.send(dataRequest); } function tempColor(){ var url = "https://api.lifx.com/v1/lights/group:<GROUP NAME>/state"; var dataRequest = '{"power" : "on", "color": "kelvin:' + hs.DeviceValue("<REFERENCE ID>") + '", "brightness" : "1"}'; var client = new ActiveXObject("Microsoft.XMLHTTP"); client.open("PUT", url, true); client.setRequestHeader("Authorization", "Bearer <API KEY>"); client.send(dataRequest); }



Comment