use POST request for modyfing light state
parent
337523e151
commit
7857e1e908
|
@ -203,15 +203,22 @@
|
|||
};
|
||||
light.element.onclick=function(light){
|
||||
return function(){
|
||||
client.publish(light.mqtt_path + "/toggle", "true");
|
||||
var toggle_request = new XMLHttpRequest();
|
||||
toggle_request.open("POST", "/light/" + light.id + "/on/toggle", true);
|
||||
toggle_request.send(JSON.stringify(true));
|
||||
};
|
||||
}(light);
|
||||
};
|
||||
//document.getElementById("up").onclick = function(){
|
||||
// for (i = 1; i <= 8; i++) {
|
||||
// client.publish("devices/light_904649/light_" + i + "/on/set", 'true');
|
||||
// };
|
||||
//};
|
||||
document.getElementById("up").onclick = function(lights){
|
||||
return function ( lights ) {
|
||||
for ( i in lights ) {
|
||||
light = lights[i];
|
||||
var toggle_request = new XMLHttpRequest();
|
||||
toggle_request.open("POST", "/light/" + light.id + "/on/set", true);
|
||||
toggle_request.send(JSON.stringify(true));
|
||||
};
|
||||
};
|
||||
}(lights);
|
||||
};
|
||||
|
||||
client.connect({
|
||||
|
|
Loading…
Reference in New Issue