Skip to content

Instantly share code, notes, and snippets.

@steam0
Last active April 22, 2016 08:22
Show Gist options
  • Save steam0/362e0ad54b21ff1e77de28328bdd07e5 to your computer and use it in GitHub Desktop.
Save steam0/362e0ad54b21ff1e77de28328bdd07e5 to your computer and use it in GitHub Desktop.
function changeGroupState() {
// Get the button and the slider
var button = document.getElementById(event.target.id);
var slider = document.getElementById("slider"+event.target.id);
var state;
state = changeButtonState(button);
var brightness;
if (state) {
brightness = 254;
} else {
brightness = 0;
}
$(("#"+slider.id)).slider('setValue', brightness);
// Generate URL
var url = ip+"/hue/group?id="+button.id+"&state="+state
put(url);
}
/* Put data on the bridge */
function put(url, data) {
$.ajax({
type: "POST",
url: url,
data: data,
contentType: "application/json; charset=utf-8",
crossDomain: true,
dataType: "json",
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment