use POST request for modyfing light state
parent
337523e151
commit
7857e1e908
|
@ -203,15 +203,22 @@
|
||||||
};
|
};
|
||||||
light.element.onclick=function(light){
|
light.element.onclick=function(light){
|
||||||
return function(){
|
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);
|
}(light);
|
||||||
};
|
};
|
||||||
//document.getElementById("up").onclick = function(){
|
document.getElementById("up").onclick = function(lights){
|
||||||
// for (i = 1; i <= 8; i++) {
|
return function ( lights ) {
|
||||||
// client.publish("devices/light_904649/light_" + i + "/on/set", 'true');
|
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({
|
client.connect({
|
||||||
|
|
Loading…
Reference in New Issue