Added some Docs

This commit is contained in:
2018-08-23 20:35:33 +02:00
parent 09d8b7781f
commit 8feb04990f
14 changed files with 323 additions and 177 deletions

View File

@@ -5,30 +5,58 @@ import java.util.Set;
import support.Rest;
/**
* Classe che permette di controllare le luci Philips Hue
*/
public class Hue {
//private String baseURL = "192.168.0.2";
//private String username = "C0vPwqjJZo5Jt9Oe5HgO6sBFFMxgoR532IxFoGmx";
private String lightsURL;// = baseURL+"/api/"+username+"/lights/";
/**
* L'url in cui si possono trovare le luci
*/
private String lightsURL; // = baseURL+"/api/"+username+"/lights/";
/**
* Tutte le luci che sono state registrate dall'url
*/
private Map<String, ?> allLights;
public Hue () {
this("http://172.30.1.138/api/C0vPwqjJZo5Jt9Oe5HgO6sBFFMxgoR532IxFoGmx/lights/");
}
/**
* Inizializza la classe cercando tutte le luci all'indirizzo url specificato
*
* @param url l'indirizzo da inserire delle luci Hue
*/
public Hue (String url) {
lightsURL = url;
allLights = Rest.get(lightsURL);
}
/**
* Ritorna un insieme contenente tutti i nomi delle luci che si sono trovate
*
* @return l'insieme dei nomi delle luci
*/
public Set<String> getNameLights() {
return allLights.keySet();
}
/**
* Rimuove dal controllo tutte le luci che hanno il nome uguale ad uno contenuto nell'insieme passato
*
* @param toRemove le luci da rimuovere
*/
public void removeLights(Set<String> toRemove) {
for(String string : toRemove)
allLights.remove(string);
}
/**
* Accende tutte le luci controllate
*/
public void turnOn() {
for (String light : allLights.keySet()) {
String callURL = lightsURL + light + "/state";
@@ -37,9 +65,9 @@ public class Hue {
}
}
public int getCurrentLuminiscence() {
return 0;
}
/**
* Spegne tutte le luci controllate
*/
public void turnOff() {
for (String light : allLights.keySet()) {
String callURL = lightsURL + light + "/state";
@@ -47,8 +75,22 @@ public class Hue {
Rest.put(callURL, body, "application/json");
}
}
/**
* Ritorna la liminosita' attuale delle luci controllate
* @return
*/
public int getCurrentBrightness() {
return 0;
}
/**
* Modifica la luminosita' delle luci a seconda del valore inserito
* @param num la luminosita' che si vuole
*/
public void setBrightness(int num) {
if (num<0)
num=0;
for (String light : allLights.keySet()) {
String callURL = lightsURL + light + "/state";
String body = "{ \"bri\" : "+num+" }";
@@ -56,14 +98,9 @@ public class Hue {
}
}
/*public void setAttribute(String attribute, String value){
for (String light : allLights.keySet()) {
String callURL = lightsURL + light + "/state";
String body = "{ \""+attribute+"\" : "+value+" }";
Rest.put(callURL, body, "application/json");
}
}*/
/**
* Modifica il colore delle luci in modo da fare un bel effetto arcobaleno continuo
*/
public void colorLoop() {
for (String light : allLights.keySet()) {
String callURL = lightsURL + light + "/state";
@@ -72,5 +109,14 @@ public class Hue {
}
}
/**
* Funzione generale per poter utilizzare qualunque valore, ma non funziona
*/
/*public void setAttribute(String attribute, String value){
for (String light : allLights.keySet()) {
String callURL = lightsURL + light + "/state";
String body = "{ \""+attribute+"\" : "+value+" }";
Rest.put(callURL, body, "application/json");
}
}*/
}