Skip to content

Commit f238e05

Browse files
committed
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
1 parent aaaebd0 commit f238e05

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.bwssystems.HABridge</groupId>
77
<artifactId>ha-bridge</artifactId>
8-
<version>2.0.0</version>
8+
<version>2.0.1</version>
99
<packaging>jar</packaging>
1010

1111
<name>HA Bridge</name>

src/main/java/com/bwssystems/HABridge/api/hue/DeviceState.java

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package com.bwssystems.HABridge.api.hue;
22

3+
import java.util.ArrayList;
34
import java.util.List;
45

56
/**
67
* Created by arm on 4/14/15.
78
*/
89
public class DeviceState {
910
private boolean on;
10-
private int bri = 255;
11+
private int bri;
1112
private int hue;
1213
private int sat;
1314
private String effect;
@@ -96,7 +97,24 @@ public List<Double> getXy() {
9697
public void setXy(List<Double> xy) {
9798
this.xy = xy;
9899
}
99-
100+
public static DeviceState createDeviceState() {
101+
DeviceState newDeviceState = new DeviceState();
102+
newDeviceState.fillIn();
103+
// newDeviceState.setColormode("none");
104+
// ArrayList<Double> doubleArray = new ArrayList<Double>();
105+
// doubleArray.add(new Double(0));
106+
// doubleArray.add(new Double(0));
107+
// newDeviceState.setXy(doubleArray);
108+
109+
return newDeviceState;
110+
}
111+
public void fillIn() {
112+
if(this.getAlert() == null)
113+
this.setAlert("none");
114+
if(this.getEffect() == null)
115+
this.setEffect("none");
116+
this.setReachable(true);
117+
}
100118
@Override
101119
public String toString() {
102120
return "DeviceState{" +

src/main/java/com/bwssystems/HABridge/dao/DeviceDescriptor.java

+2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ public void setContentBodyOff(String contentBodyOff) {
166166
}
167167

168168
public DeviceState getDeviceState() {
169+
if(deviceState == null)
170+
deviceState = DeviceState.createDeviceState();
169171
return deviceState;
170172
}
171173

src/main/java/com/bwssystems/HABridge/hue/HueMulator.java

+1
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ public void setupServer() {
381381
responseString = "[{\"error\":{\"type\": 3, \"address\": \"/lights/" + lightId + "\",\"description\": \"Could not find device\", \"resource\": \"/lights/" + lightId + "\"}}]";
382382
return responseString;
383383
}
384+
state.fillIn();
384385

385386
theHeaders = new Gson().fromJson(device.getHeaders(), NameValue[].class);
386387
responseString = this.formatSuccessHueResponse(state, request.body(), lightId);

0 commit comments

Comments
 (0)