Compare commits

..

1 Commits

Author SHA1 Message Date
Admin
f238e05533 Fixed bug where device state object was dropped from hue api device
response object. This caused devices to appear offline and invalid
response interpretation by the echo.

Fixes #93
2016-04-28 12:12:49 -05:00
4 changed files with 24 additions and 3 deletions

View File

@@ -5,7 +5,7 @@
<groupId>com.bwssystems.HABridge</groupId> <groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId> <artifactId>ha-bridge</artifactId>
<version>2.0.0</version> <version>2.0.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>HA Bridge</name> <name>HA Bridge</name>

View File

@@ -1,5 +1,6 @@
package com.bwssystems.HABridge.api.hue; package com.bwssystems.HABridge.api.hue;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@@ -7,7 +8,7 @@ import java.util.List;
*/ */
public class DeviceState { public class DeviceState {
private boolean on; private boolean on;
private int bri = 255; private int bri;
private int hue; private int hue;
private int sat; private int sat;
private String effect; private String effect;
@@ -96,7 +97,24 @@ public class DeviceState {
public void setXy(List<Double> xy) { public void setXy(List<Double> xy) {
this.xy = xy; this.xy = xy;
} }
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);
return newDeviceState;
}
public void fillIn() {
if(this.getAlert() == null)
this.setAlert("none");
if(this.getEffect() == null)
this.setEffect("none");
this.setReachable(true);
}
@Override @Override
public String toString() { public String toString() {
return "DeviceState{" + return "DeviceState{" +

View File

@@ -166,6 +166,8 @@ public class DeviceDescriptor{
} }
public DeviceState getDeviceState() { public DeviceState getDeviceState() {
if(deviceState == null)
deviceState = DeviceState.createDeviceState();
return deviceState; return deviceState;
} }

View File

@@ -381,6 +381,7 @@ public class HueMulator implements HueErrorStringSet {
responseString = "[{\"error\":{\"type\": 3, \"address\": \"/lights/" + lightId + "\",\"description\": \"Could not find device\", \"resource\": \"/lights/" + lightId + "\"}}]"; responseString = "[{\"error\":{\"type\": 3, \"address\": \"/lights/" + lightId + "\",\"description\": \"Could not find device\", \"resource\": \"/lights/" + lightId + "\"}}]";
return responseString; return responseString;
} }
state.fillIn();
theHeaders = new Gson().fromJson(device.getHeaders(), NameValue[].class); theHeaders = new Gson().fromJson(device.getHeaders(), NameValue[].class);
responseString = this.formatSuccessHueResponse(state, request.body(), lightId); responseString = this.formatSuccessHueResponse(state, request.body(), lightId);