Branch #Dawit (this was a test)

* lampadine funzionano
* Aggiunto classe Sensor e testSensor. NON SO se giusto
* Aggiunto jar per Z-Wave
* Removed .gradle .idea
This commit was merged in pull request #1.
This commit is contained in:
Dawit Gulino 20013954
2018-06-01 21:36:47 +02:00
committed by Giacomo Bertolazzi 20015159
parent fc135908f5
commit 9d995e093e
20 changed files with 352 additions and 1159 deletions

View File

@@ -1,23 +1,34 @@
package device;
import java.util.Map;
import java.util.Set;
import manage.Rest;
public class Hue {
//private String baseURL;// = "192.168.0.2";
//private String username;// = "admin";
//private String baseURL = "192.168.0.2";
//private String username = "C0vPwqjJZo5Jt9Oe5HgO6sBFFMxgoR532IxFoGmx";
private String lightsURL;// = baseURL+"/api/"+username+"/lights/";
private Map<String, ?> allLights;
public Hue () {
this("192.168.0.2/api/admin/lights/");
this("http://172.30.1.138/api/C0vPwqjJZo5Jt9Oe5HgO6sBFFMxgoR532IxFoGmx/lights/");
}
public Hue (String url) {
lightsURL = url;
allLights = Rest.get(lightsURL);
}
public Set<String> getNameLights() {
return allLights.keySet();
}
public void removeLights(Set<String> toRemove) {
for(String string : toRemove)
allLights.remove(string);
}
public void turnOn() {
for (String light : allLights.keySet()) {
String callURL = lightsURL + light + "/state";
@@ -42,12 +53,20 @@ public class Hue {
}
}
public void setAttribute(String attribute, String value){
/*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");
}
}*/
public void colorLoop() {
for (String light : allLights.keySet()) {
String callURL = lightsURL + light + "/state";
String body = "{ \"on\" : true, \"effect\" : \"colorloop\" }";
Rest.put(callURL, body, "application/json");
}
}