Added device data value passing, off state change for brigthness, hex

intensity values, updatd ui to cgo back to device touched after
edit/add.
This commit is contained in:
Admin
2017-03-17 16:53:21 -05:00
parent 0c4292bfd7
commit bb0ffeb570
18 changed files with 326 additions and 65 deletions

View File

@@ -391,7 +391,7 @@ public class HueMulator {
}
private String formatSuccessHueResponse(StateChangeBody stateChanges, String body, String lightId,
DeviceState deviceState, Integer targetBri, Integer targetBriInc) {
DeviceState deviceState, Integer targetBri, Integer targetBriInc, boolean offState) {
String responseString = "[";
boolean notFirstChange = false;
@@ -406,6 +406,8 @@ public class HueMulator {
deviceState.setOn(stateChanges.isOn());
if(!deviceState.isOn() && deviceState.getBri() == 254)
deviceState.setBri(0);
if(!deviceState.isOn() && offState)
deviceState.setBri(0);
}
notFirstChange = true;
}
@@ -824,7 +826,7 @@ public class HueMulator {
if (state == null)
state = DeviceState.createDeviceState();
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, state, targetBri, targetBriInc);
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, state, targetBri, targetBriInc, device.isOffState());
device.setDeviceState(state);
return responseString;
@@ -964,11 +966,11 @@ public class HueMulator {
if (responseString == null || !responseString.contains("[{\"error\":")) {
if(!device.isNoState()) {
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, state, targetBri, targetBriInc);
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, state, targetBri, targetBriInc, device.isOffState());
device.setDeviceState(state);
} else {
DeviceState dummyState = DeviceState.createDeviceState();
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, dummyState, targetBri, targetBriInc);
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, dummyState, targetBri, targetBriInc, device.isOffState());
}
}
return responseString;