diff --git a/src/main/java/com/bwssystems/HABridge/api/hue/DeviceResponse.java b/src/main/java/com/bwssystems/HABridge/api/hue/DeviceResponse.java index 99c61bd..2366276 100644 --- a/src/main/java/com/bwssystems/HABridge/api/hue/DeviceResponse.java +++ b/src/main/java/com/bwssystems/HABridge/api/hue/DeviceResponse.java @@ -105,26 +105,19 @@ public class DeviceResponse { response.setName(device.getName()); response.setUniqueid(device.getUniqueid()); - //if (device.getColorUrl() == null || device.getColorUrl().trim().equals("")) { - // if (device.getDimUrl() == null || device.getDimUrl().trim().equals("")) { - // response.setType("On/Off light"); - // response.setModelid("Plug - LIGHTIFY"); - // response.setManufacturername("OSRAM"); - // response.setSwversion("V1.04.12"); - // } else { - // response.setManufacturername("Philips"); - // response.setType("Dimmable light"); - // response.setModelid("LWB007"); - // response.setSwversion("66012040"); - // } - //} else { - response.setManufacturername("Philips"); + response.setManufacturername("Philips"); + + if (device.isColorDevice()) { response.setType("Extended color light"); response.setModelid("LCT010"); response.setSwversion("1.15.2_r19181"); response.setSwconfigid("F921C859"); response.setProductid("Philips-LCT010-1-A19ECLv4"); - //} + } else { + response.setType("Dimmable light"); + response.setModelid("LWB007"); + response.setSwversion("66012040"); + } response.setLuminaireuniqueid(null); diff --git a/src/main/java/com/bwssystems/HABridge/api/hue/DeviceState.java b/src/main/java/com/bwssystems/HABridge/api/hue/DeviceState.java index c3bcbac..4ff008b 100644 --- a/src/main/java/com/bwssystems/HABridge/api/hue/DeviceState.java +++ b/src/main/java/com/bwssystems/HABridge/api/hue/DeviceState.java @@ -9,11 +9,11 @@ import java.util.List; public class DeviceState { private boolean on; private int bri; - private int hue; - private int sat; + private Integer hue; + private Integer sat; private String effect; private List xy; - private int ct; + private Integer ct; private String alert; private String colormode; private boolean reachable; @@ -37,7 +37,7 @@ public class DeviceState { } public int getHue() { - return hue; + return hue != null ? hue.intValue() : 0; } public void setHue(int hue) { @@ -46,7 +46,7 @@ public class DeviceState { } public int getSat() { - return sat; + return sat != null ? sat.intValue() : 0; } public void setSat(int sat) { @@ -63,7 +63,7 @@ public class DeviceState { } public int getCt() { - return ct; + return ct != null ? ct.intValue() : 0; } public void setCt(int ct) { @@ -111,23 +111,28 @@ public class DeviceState { // this.transitiontime = transitiontime; // } - public static DeviceState createDeviceState() { + public static DeviceState createDeviceState(boolean color) { DeviceState newDeviceState = new DeviceState(); - newDeviceState.fillIn(); - newDeviceState.setColormode("ct"); - newDeviceState.setCt(200); - ArrayList doubleArray = new ArrayList(); - doubleArray.add(new Double(0)); - doubleArray.add(new Double(0)); - newDeviceState.setXy(doubleArray); - + newDeviceState.fillIn(color); + if (color) { + newDeviceState.setColormode("xy"); + newDeviceState.setHue(0); + newDeviceState.setSat(0); + newDeviceState.setCt(153); + ArrayList doubleArray = new ArrayList(); + doubleArray.add(0.3146); + doubleArray.add(0.3303); + newDeviceState.setXy(doubleArray); + } return newDeviceState; } - public void fillIn() { + public void fillIn(boolean color) { if(this.getAlert() == null) this.setAlert("none"); - if(this.getEffect() == null) - this.setEffect("none"); + if (color) { + if(this.getEffect() == null) + this.setEffect("none"); + } this.setReachable(true); } @Override diff --git a/src/main/java/com/bwssystems/HABridge/api/hue/GroupResponse.java b/src/main/java/com/bwssystems/HABridge/api/hue/GroupResponse.java index 573f517..c44b0b0 100644 --- a/src/main/java/com/bwssystems/HABridge/api/hue/GroupResponse.java +++ b/src/main/java/com/bwssystems/HABridge/api/hue/GroupResponse.java @@ -82,7 +82,7 @@ public class GroupResponse { i++; } GroupResponse theResponse = new GroupResponse(); - theResponse.setAction(DeviceState.createDeviceState()); + theResponse.setAction(DeviceState.createDeviceState(true)); theResponse.setState(new GroupState(all_on, any_on)); theResponse.setName("Group 0"); theResponse.setLights(theList); diff --git a/src/main/java/com/bwssystems/HABridge/dao/DeviceDescriptor.java b/src/main/java/com/bwssystems/HABridge/dao/DeviceDescriptor.java index 26bfdec..1d2b4ee 100644 --- a/src/main/java/com/bwssystems/HABridge/dao/DeviceDescriptor.java +++ b/src/main/java/com/bwssystems/HABridge/dao/DeviceDescriptor.java @@ -219,7 +219,7 @@ public class DeviceDescriptor{ public DeviceState getDeviceState() { if(deviceState == null) - deviceState = DeviceState.createDeviceState(); + deviceState = DeviceState.createDeviceState(this.isColorDevice()); return deviceState; } @@ -299,4 +299,16 @@ public class DeviceDescriptor{ return false; } + + public boolean isColorDevice() { + boolean color = true; + if ((deviceType == null || !deviceType.trim().equals("passthru")) && (colorUrl == null || colorUrl.trim().equals(""))) { + color = false; + } else if (deviceType != null && deviceType.trim().equals("passthru")) { + if (deviceState != null && (deviceState.getColormode() == null || deviceState.getColormode().equals(""))) { + color = false; + } + } + return color; + } } \ No newline at end of file diff --git a/src/main/java/com/bwssystems/HABridge/dao/GroupDescriptor.java b/src/main/java/com/bwssystems/HABridge/dao/GroupDescriptor.java index 2c134e5..013b89d 100644 --- a/src/main/java/com/bwssystems/HABridge/dao/GroupDescriptor.java +++ b/src/main/java/com/bwssystems/HABridge/dao/GroupDescriptor.java @@ -90,7 +90,7 @@ public class GroupDescriptor{ public DeviceState getAction() { if(action == null) - action = DeviceState.createDeviceState(); + action = DeviceState.createDeviceState(true); return action; } diff --git a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java index 1633fc0..c5c7c75 100644 --- a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java +++ b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java @@ -1073,7 +1073,7 @@ public class HueMulator { state = device.getDeviceState(); if (state == null) - state = DeviceState.createDeviceState(); + state = DeviceState.createDeviceState(device.isColorDevice()); responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, state, targetBri, targetBriInc, device.isOffState()); device.setDeviceState(state); @@ -1127,7 +1127,7 @@ public class HueMulator { state = device.getDeviceState(); if (state == null) { - state = DeviceState.createDeviceState(); + state = DeviceState.createDeviceState(device.isColorDevice()); device.setDeviceState(state); } @@ -1248,7 +1248,7 @@ public class HueMulator { responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, state, targetBri, targetBriInc, device.isOffState()); device.setDeviceState(state); } else { - DeviceState dummyState = DeviceState.createDeviceState(); + DeviceState dummyState = DeviceState.createDeviceState(device.isColorDevice()); responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, dummyState, targetBri, targetBriInc, device.isOffState()); } } @@ -1309,7 +1309,7 @@ public class HueMulator { state = group.getAction(); if (state == null) { - state = DeviceState.createDeviceState(); + state = DeviceState.createDeviceState(true); group.setAction(state); } } diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js index 6c4de53..e1a8839 100644 --- a/src/main/resources/public/scripts/app.js +++ b/src/main/resources/public/scripts/app.js @@ -134,7 +134,8 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n this.state = {base: "./api/devices", bridgelocation: ".", systemsbase: "./system", huebase: "./api", configs: [], backups: [], devices: [], device: {}, mapandid: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], mapTypes: [], olddevicename: "", logShowAll: false, isInControl: false, showVera: false, showHarmony: false, showNest: false, showHue: false, showHal: false, showMqtt: false, showHass: false, - showDomoticz: false, showSomfy: false, showLifx: false, habridgeversion: {}, viewDevId: "", queueDevId: "", securityInfo: {}, filterDevicesByIpAddress: null}; + showDomoticz: false, showSomfy: false, showLifx: false, habridgeversion: {}, viewDevId: "", queueDevId: "", securityInfo: {}, filterDevicesByIpAddress: null, + filterDevicesOnlyFiltered: false, filterDeviceType: null}; this.displayWarn = function(errorTitle, error) { var toastContent = errorTitle; @@ -3463,13 +3464,39 @@ app.filter('configuredSomfyDevices', function (bridgeService) { }); app.filter('filterDevicesByRequester', function () { - return function(input,search) { + return function(input,search,mustContain,deviceType) { var out = []; if(input === undefined || input === null || input.length === undefined) return out; var pattern = new RegExp(search); + var patternType = new RegExp(deviceType); for (var i = 0; i < input.length; i++) { - if(pattern.test(input[i].requesterAddress) || !input[i].requesterAddress || input[i].requesterAddress.length === 0){ + var pushRequester = false; + var pushType = false; + + // Check filter by requester + if (!search || search.trim().length === 0) { // if search is empty and mustContain == true push only unfiltered devices + if (mustContain) { + if (!input[i].requesterAddress || input[i].requesterAddress.length === 0) { + pushRequester = true; + } + } else { + pushRequester = true; + } + } else { + if(pattern.test(input[i].requesterAddress) || !mustContain && (!input[i].requesterAddress || input[i].requesterAddress.length === 0)){ + pushRequester = true; + } + } + + // Check filter by deviceType + if (deviceType) { + pushType = patternType.test(input[i].deviceType); + } else { + pushType = true; + } + + if (pushRequester && pushType) { out.push(input[i]); } } diff --git a/src/main/resources/public/views/configuration.html b/src/main/resources/public/views/configuration.html index 0060600..0f1705f 100644 --- a/src/main/resources/public/views/configuration.html +++ b/src/main/resources/public/views/configuration.html @@ -37,6 +37,25 @@ + Must contain filter + + @@ -55,7 +74,7 @@ Actions - + {{$index+1}} {{device.id}} {{device.name}}