Added ColorUrl and alternative item edit mode

Additional to on/off/dim items i added color items. The colorUrl gets executed if a PUT is received with xy/ct/hue/sat in the body. Also changed the emulated bulb type to "Extended color light".
Added "Change Editmode" button in the editdevice screen. Switch between manual JSON edit and the tabular variant. Local unsaved changes in one mode carry over to the other. Through this edit variant it's possible to change the order of items and do copy/paste.
This commit is contained in:
Unknown
2017-07-23 10:15:00 +02:00
parent 430eff958c
commit 3a5262ff33
6 changed files with 456 additions and 164 deletions

View File

@@ -14,6 +14,8 @@ public class DeviceResponse {
private String luminaireuniqueid;
private String uniqueid;
private String swversion;
private String swconfigid;
private String productid;
public DeviceState getState() {
return state;
@@ -71,6 +73,23 @@ public class DeviceResponse {
this.swversion = swversion;
}
public String getSwconfigid() {
return swconfigid;
}
public void setSwconfigid(String swconfigid) {
this.swconfigid = swconfigid;
}
public String getProductid() {
return productid;
}
public void setProductid(String productid) {
this.productid = productid;
}
public String getLuminaireuniqueid() {
return luminaireuniqueid;
}
@@ -86,9 +105,11 @@ public class DeviceResponse {
response.setName(device.getName());
response.setUniqueid(device.getUniqueid());
response.setManufacturername("Philips");
response.setType("Dimmable light");
response.setModelid("LWB004");
response.setSwversion("66012040");
response.setType("Extended color light");
response.setModelid("LCT010");
response.setSwversion("1.15.2_r19181");
response.setSwconfigid("F921C859");
response.setProductid("Philips-LCT010-1-A19ECLv4");
response.setLuminaireuniqueid(null);
return response;

View File

@@ -1,6 +1,6 @@
package com.bwssystems.HABridge.api.hue;
// import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
/**
@@ -12,11 +12,12 @@ public class DeviceState {
private int hue;
private int sat;
private String effect;
private List<Double> xy;
private int ct;
private String alert;
private String colormode;
private boolean reachable;
private List<Double> xy;
// private int transitiontime;
public boolean isOn() {
@@ -41,6 +42,7 @@ public class DeviceState {
public void setHue(int hue) {
this.hue = hue;
this.colormode = "hs";
}
public int getSat() {
@@ -49,6 +51,7 @@ public class DeviceState {
public void setSat(int sat) {
this.sat = sat;
this.colormode = "hs";
}
public String getEffect() {
@@ -65,6 +68,7 @@ public class DeviceState {
public void setCt(int ct) {
this.ct = ct;
this.colormode = "ct";
}
public String getAlert() {
@@ -97,6 +101,7 @@ public class DeviceState {
public void setXy(List<Double> xy) {
this.xy = xy;
this.colormode = "xy";
}
// public int getTransitiontime() {
// return transitiontime;
@@ -109,11 +114,12 @@ public class DeviceState {
public static DeviceState createDeviceState() {
DeviceState newDeviceState = new DeviceState();
newDeviceState.fillIn();
// newDeviceState.setColormode("none");
// ArrayList<Double> doubleArray = new ArrayList<Double>();
// doubleArray.add(new Double(0));
// doubleArray.add(new Double(0));
// newDeviceState.setXy(doubleArray);
newDeviceState.setColormode("ct");
newDeviceState.setCt(200);
ArrayList<Double> doubleArray = new ArrayList<Double>();
doubleArray.add(new Double(0));
doubleArray.add(new Double(0));
newDeviceState.setXy(doubleArray);
return newDeviceState;
}

View File

@@ -38,6 +38,9 @@ public class DeviceDescriptor{
@SerializedName("onUrl")
@Expose
private String onUrl;
@SerializedName("colorUrl")
@Expose
private String colorUrl;
@SerializedName("headers")
@Expose
private String headers;
@@ -142,6 +145,14 @@ public class DeviceDescriptor{
this.onUrl = onUrl;
}
public String getColorUrl() {
return colorUrl;
}
public void setColorUrl(String colorUrl) {
this.colorUrl = colorUrl;
}
public String getId() {
return id;
}
@@ -282,6 +293,9 @@ public class DeviceDescriptor{
if(this.offUrl != null && this.offUrl.contains(aType))
return true;
if(this.colorUrl != null && this.colorUrl.contains(aType))
return true;
return false;
}

View File

@@ -467,16 +467,6 @@ public class HueMulator {
notFirstChange = true;
}
if (body.contains("\"ct\"")) {
if (notFirstChange)
responseString = responseString + ",";
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/ct\":" + stateChanges.getCt()
+ "}}";
if (deviceState != null)
deviceState.setCt(stateChanges.getCt());
notFirstChange = true;
}
if (body.contains("\"xy\"")) {
if (notFirstChange)
responseString = responseString + ",";
@@ -485,36 +475,34 @@ public class HueMulator {
if (deviceState != null)
deviceState.setXy(stateChanges.getXy());
notFirstChange = true;
}
if (body.contains("\"hue\"")) {
} else if (body.contains("\"ct\"")) {
if (notFirstChange)
responseString = responseString + ",";
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/hue\":" + stateChanges.getHue()
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/ct\":" + stateChanges.getCt()
+ "}}";
if (deviceState != null)
deviceState.setHue(stateChanges.getHue());
deviceState.setCt(stateChanges.getCt());
notFirstChange = true;
}
} else {
if (body.contains("\"hue\"")) {
if (notFirstChange)
responseString = responseString + ",";
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/hue\":" + stateChanges.getHue()
+ "}}";
if (deviceState != null)
deviceState.setHue(stateChanges.getHue());
notFirstChange = true;
}
if (body.contains("\"sat\"")) {
if (notFirstChange)
responseString = responseString + ",";
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/sat\":" + stateChanges.getSat()
+ "}}";
if (deviceState != null)
deviceState.setSat(stateChanges.getSat());
notFirstChange = true;
}
if (body.contains("\"ct_inc\"")) {
if (notFirstChange)
responseString = responseString + ",";
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/ct_inc\":"
+ stateChanges.getCt_inc() + "}}";
if (deviceState != null)
deviceState.setCt(deviceState.getCt() + stateChanges.getCt_inc());
notFirstChange = true;
if (body.contains("\"sat\"")) {
if (notFirstChange)
responseString = responseString + ",";
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/sat\":" + stateChanges.getSat()
+ "}}";
if (deviceState != null)
deviceState.setSat(stateChanges.getSat());
notFirstChange = true;
}
}
if (body.contains("\"xy_inc\"")) {
@@ -525,26 +513,34 @@ public class HueMulator {
if (deviceState != null)
deviceState.setXy(stateChanges.getXy());
notFirstChange = true;
}
if (body.contains("\"hue_inc\"")) {
} else if (body.contains("\"ct_inc\"")) {
if (notFirstChange)
responseString = responseString + ",";
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/hue_inc\":"
+ stateChanges.getHue_inc() + "}}";
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/ct_inc\":"
+ stateChanges.getCt_inc() + "}}";
if (deviceState != null)
deviceState.setHue(deviceState.getHue() + stateChanges.getHue_inc());
deviceState.setCt(deviceState.getCt() + stateChanges.getCt_inc());
notFirstChange = true;
}
} else {
if (body.contains("\"hue_inc\"")) {
if (notFirstChange)
responseString = responseString + ",";
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/hue_inc\":"
+ stateChanges.getHue_inc() + "}}";
if (deviceState != null)
deviceState.setHue(deviceState.getHue() + stateChanges.getHue_inc());
notFirstChange = true;
}
if (body.contains("\"sat_inc\"")) {
if (notFirstChange)
responseString = responseString + ",";
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/sat_inc\":"
+ stateChanges.getSat_inc() + "}}";
if (deviceState != null)
deviceState.setSat(deviceState.getSat() + stateChanges.getSat_inc());
notFirstChange = true;
if (body.contains("\"sat_inc\"")) {
if (notFirstChange)
responseString = responseString + ",";
responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/sat_inc\":"
+ stateChanges.getSat_inc() + "}}";
if (deviceState != null)
deviceState.setSat(deviceState.getSat() + stateChanges.getSat_inc());
notFirstChange = true;
}
}
if (body.contains("\"effect\"")) {
@@ -931,7 +927,9 @@ public class HueMulator {
if (url == null || url.length() == 0)
url = device.getOnUrl();
} else {
if (theStateChanges.isOn()) {
if (body.contains("\"xy\"") || body.contains("\"ct\"") || body.contains("\"hue\"")) {
url = device.getColorUrl();
} else if (theStateChanges.isOn()) {
url = device.getOnUrl();
} else if (!theStateChanges.isOn()) {
url = device.getOffUrl();