use POST request for modyfing light state

master
vuko 2020-11-24 10:58:42 +01:00
parent 337523e151
commit 7857e1e908
1 changed files with 13 additions and 6 deletions

View File

@ -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({