mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 16:17:30 +00:00
Merge pull request #715 from FloFoer/FeaturesfFor5.0
Light type detection and filter for device list
This commit is contained in:
@@ -105,26 +105,19 @@ public class DeviceResponse {
|
|||||||
|
|
||||||
response.setName(device.getName());
|
response.setName(device.getName());
|
||||||
response.setUniqueid(device.getUniqueid());
|
response.setUniqueid(device.getUniqueid());
|
||||||
//if (device.getColorUrl() == null || device.getColorUrl().trim().equals("")) {
|
response.setManufacturername("Philips");
|
||||||
// if (device.getDimUrl() == null || device.getDimUrl().trim().equals("")) {
|
|
||||||
// response.setType("On/Off light");
|
if (device.isColorDevice()) {
|
||||||
// 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.setType("Extended color light");
|
response.setType("Extended color light");
|
||||||
response.setModelid("LCT010");
|
response.setModelid("LCT010");
|
||||||
response.setSwversion("1.15.2_r19181");
|
response.setSwversion("1.15.2_r19181");
|
||||||
response.setSwconfigid("F921C859");
|
response.setSwconfigid("F921C859");
|
||||||
response.setProductid("Philips-LCT010-1-A19ECLv4");
|
response.setProductid("Philips-LCT010-1-A19ECLv4");
|
||||||
//}
|
} else {
|
||||||
|
response.setType("Dimmable light");
|
||||||
|
response.setModelid("LWB007");
|
||||||
|
response.setSwversion("66012040");
|
||||||
|
}
|
||||||
|
|
||||||
response.setLuminaireuniqueid(null);
|
response.setLuminaireuniqueid(null);
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ import java.util.List;
|
|||||||
public class DeviceState {
|
public class DeviceState {
|
||||||
private boolean on;
|
private boolean on;
|
||||||
private int bri;
|
private int bri;
|
||||||
private int hue;
|
private Integer hue;
|
||||||
private int sat;
|
private Integer sat;
|
||||||
private String effect;
|
private String effect;
|
||||||
private List<Double> xy;
|
private List<Double> xy;
|
||||||
private int ct;
|
private Integer ct;
|
||||||
private String alert;
|
private String alert;
|
||||||
private String colormode;
|
private String colormode;
|
||||||
private boolean reachable;
|
private boolean reachable;
|
||||||
@@ -37,7 +37,7 @@ public class DeviceState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getHue() {
|
public int getHue() {
|
||||||
return hue;
|
return hue != null ? hue.intValue() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHue(int hue) {
|
public void setHue(int hue) {
|
||||||
@@ -46,7 +46,7 @@ public class DeviceState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getSat() {
|
public int getSat() {
|
||||||
return sat;
|
return sat != null ? sat.intValue() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSat(int sat) {
|
public void setSat(int sat) {
|
||||||
@@ -63,7 +63,7 @@ public class DeviceState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getCt() {
|
public int getCt() {
|
||||||
return ct;
|
return ct != null ? ct.intValue() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCt(int ct) {
|
public void setCt(int ct) {
|
||||||
@@ -111,23 +111,28 @@ public class DeviceState {
|
|||||||
// this.transitiontime = transitiontime;
|
// this.transitiontime = transitiontime;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public static DeviceState createDeviceState() {
|
public static DeviceState createDeviceState(boolean color) {
|
||||||
DeviceState newDeviceState = new DeviceState();
|
DeviceState newDeviceState = new DeviceState();
|
||||||
newDeviceState.fillIn();
|
newDeviceState.fillIn(color);
|
||||||
newDeviceState.setColormode("ct");
|
if (color) {
|
||||||
newDeviceState.setCt(200);
|
newDeviceState.setColormode("xy");
|
||||||
ArrayList<Double> doubleArray = new ArrayList<Double>();
|
newDeviceState.setHue(0);
|
||||||
doubleArray.add(new Double(0));
|
newDeviceState.setSat(0);
|
||||||
doubleArray.add(new Double(0));
|
newDeviceState.setCt(153);
|
||||||
newDeviceState.setXy(doubleArray);
|
ArrayList<Double> doubleArray = new ArrayList<Double>();
|
||||||
|
doubleArray.add(0.3146);
|
||||||
|
doubleArray.add(0.3303);
|
||||||
|
newDeviceState.setXy(doubleArray);
|
||||||
|
}
|
||||||
return newDeviceState;
|
return newDeviceState;
|
||||||
}
|
}
|
||||||
public void fillIn() {
|
public void fillIn(boolean color) {
|
||||||
if(this.getAlert() == null)
|
if(this.getAlert() == null)
|
||||||
this.setAlert("none");
|
this.setAlert("none");
|
||||||
if(this.getEffect() == null)
|
if (color) {
|
||||||
this.setEffect("none");
|
if(this.getEffect() == null)
|
||||||
|
this.setEffect("none");
|
||||||
|
}
|
||||||
this.setReachable(true);
|
this.setReachable(true);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class GroupResponse {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
GroupResponse theResponse = new GroupResponse();
|
GroupResponse theResponse = new GroupResponse();
|
||||||
theResponse.setAction(DeviceState.createDeviceState());
|
theResponse.setAction(DeviceState.createDeviceState(true));
|
||||||
theResponse.setState(new GroupState(all_on, any_on));
|
theResponse.setState(new GroupState(all_on, any_on));
|
||||||
theResponse.setName("Group 0");
|
theResponse.setName("Group 0");
|
||||||
theResponse.setLights(theList);
|
theResponse.setLights(theList);
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ public class DeviceDescriptor{
|
|||||||
|
|
||||||
public DeviceState getDeviceState() {
|
public DeviceState getDeviceState() {
|
||||||
if(deviceState == null)
|
if(deviceState == null)
|
||||||
deviceState = DeviceState.createDeviceState();
|
deviceState = DeviceState.createDeviceState(this.isColorDevice());
|
||||||
return deviceState;
|
return deviceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,4 +299,16 @@ public class DeviceDescriptor{
|
|||||||
|
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ public class GroupDescriptor{
|
|||||||
|
|
||||||
public DeviceState getAction() {
|
public DeviceState getAction() {
|
||||||
if(action == null)
|
if(action == null)
|
||||||
action = DeviceState.createDeviceState();
|
action = DeviceState.createDeviceState(true);
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1073,7 +1073,7 @@ public class HueMulator {
|
|||||||
|
|
||||||
state = device.getDeviceState();
|
state = device.getDeviceState();
|
||||||
if (state == null)
|
if (state == null)
|
||||||
state = DeviceState.createDeviceState();
|
state = DeviceState.createDeviceState(device.isColorDevice());
|
||||||
|
|
||||||
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, state, targetBri, targetBriInc, device.isOffState());
|
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, state, targetBri, targetBriInc, device.isOffState());
|
||||||
device.setDeviceState(state);
|
device.setDeviceState(state);
|
||||||
@@ -1127,7 +1127,7 @@ public class HueMulator {
|
|||||||
|
|
||||||
state = device.getDeviceState();
|
state = device.getDeviceState();
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
state = DeviceState.createDeviceState();
|
state = DeviceState.createDeviceState(device.isColorDevice());
|
||||||
device.setDeviceState(state);
|
device.setDeviceState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1248,7 +1248,7 @@ public class HueMulator {
|
|||||||
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, state, targetBri, targetBriInc, device.isOffState());
|
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, state, targetBri, targetBriInc, device.isOffState());
|
||||||
device.setDeviceState(state);
|
device.setDeviceState(state);
|
||||||
} else {
|
} else {
|
||||||
DeviceState dummyState = DeviceState.createDeviceState();
|
DeviceState dummyState = DeviceState.createDeviceState(device.isColorDevice());
|
||||||
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, dummyState, targetBri, targetBriInc, device.isOffState());
|
responseString = this.formatSuccessHueResponse(theStateChanges, body, lightId, dummyState, targetBri, targetBriInc, device.isOffState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1309,7 +1309,7 @@ public class HueMulator {
|
|||||||
|
|
||||||
state = group.getAction();
|
state = group.getAction();
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
state = DeviceState.createDeviceState();
|
state = DeviceState.createDeviceState(true);
|
||||||
group.setAction(state);
|
group.setAction(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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: {},
|
this.state = {base: "./api/devices", bridgelocation: ".", systemsbase: "./system", huebase: "./api", configs: [], backups: [], devices: [], device: {},
|
||||||
mapandid: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], mapTypes: [], olddevicename: "", logShowAll: false,
|
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,
|
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) {
|
this.displayWarn = function(errorTitle, error) {
|
||||||
var toastContent = errorTitle;
|
var toastContent = errorTitle;
|
||||||
@@ -3463,13 +3464,39 @@ app.filter('configuredSomfyDevices', function (bridgeService) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.filter('filterDevicesByRequester', function () {
|
app.filter('filterDevicesByRequester', function () {
|
||||||
return function(input,search) {
|
return function(input,search,mustContain,deviceType) {
|
||||||
var out = [];
|
var out = [];
|
||||||
if(input === undefined || input === null || input.length === undefined)
|
if(input === undefined || input === null || input.length === undefined)
|
||||||
return out;
|
return out;
|
||||||
var pattern = new RegExp(search);
|
var pattern = new RegExp(search);
|
||||||
|
var patternType = new RegExp(deviceType);
|
||||||
for (var i = 0; i < input.length; i++) {
|
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]);
|
out.push(input[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,25 @@
|
|||||||
<label for="device-ip-filter">Show devices visible to: </label>
|
<label for="device-ip-filter">Show devices visible to: </label>
|
||||||
<input type="text" id="device-ip-filter" style="width:150px"
|
<input type="text" id="device-ip-filter" style="width:150px"
|
||||||
ng-model="bridge.state.filterDevicesByIpAddress" placeholder="">
|
ng-model="bridge.state.filterDevicesByIpAddress" placeholder="">
|
||||||
|
<input type="checkbox" id="device-ip-filter-mode" ng-model="bridge.state.filterDevicesOnlyFiltered" ng-true-value=true ng-false-value=false style="margin-right: 3px">Must contain filter
|
||||||
|
<label for="device-type-filter" style="margin-left:50px">Filter device type: </label>
|
||||||
|
<select name="device-type" id="device-type-filter"
|
||||||
|
ng-model="bridge.state.filterDeviceType">
|
||||||
|
<option value="">---No Filter---</option>
|
||||||
|
<!-- not selected / blank option -->
|
||||||
|
<option value="custom">Custom</option>
|
||||||
|
<option value="UDP">UDP</option>
|
||||||
|
<option value="TCP">TCP</option>
|
||||||
|
<option value="exec">Execute Script/Program</option>
|
||||||
|
<option value="switch">Switch</option>
|
||||||
|
<option value="scene">Scene</option>
|
||||||
|
<option value="macro">Macro</option>
|
||||||
|
<option value="group">Group</option>
|
||||||
|
<option value="activity">Activity</option>
|
||||||
|
<option value="button">Button</option>
|
||||||
|
<option value="thermo">Thermo</option>
|
||||||
|
<option value="passthru">Pass Thru</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<scrollable-table watch="bridge.devices">
|
<scrollable-table watch="bridge.devices">
|
||||||
@@ -55,7 +74,7 @@
|
|||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr ng-repeat="device in bridge.devices | orderBy:'name' | filterDevicesByRequester:bridge.state.filterDevicesByIpAddress" row-id="{{device.id}}" ng-class="{info: bridge.viewDevId == device.id}" >
|
<tr ng-repeat="device in bridge.devices | orderBy:'name' | filterDevicesByRequester:bridge.state.filterDevicesByIpAddress:bridge.state.filterDevicesOnlyFiltered:bridge.state.filterDeviceType" row-id="{{device.id}}" ng-class="{info: bridge.viewDevId == device.id}" >
|
||||||
<td>{{$index+1}}</td>
|
<td>{{$index+1}}</td>
|
||||||
<td>{{device.id}}</td>
|
<td>{{device.id}}</td>
|
||||||
<td>{{device.name}}</td>
|
<td>{{device.name}}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user