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 8d25c60..b27050e 100644 --- a/src/main/java/com/bwssystems/HABridge/api/hue/DeviceResponse.java +++ b/src/main/java/com/bwssystems/HABridge/api/hue/DeviceResponse.java @@ -14,6 +14,8 @@ public class DeviceResponse { private String luminaireuniqueid; private String uniqueid; private String swversion; + private String swconfigid; + private String productid; public DeviceState getState() { return state; @@ -71,6 +73,23 @@ public class DeviceResponse { this.swversion = swversion; } + public String getSwconfigid() { + return swconfigid; + } + + public void setSwconfigid(String swconfigid) { + this.swconfigid = swconfigid; + } + + public String getProductid() { + return productid; + } + + public void setProductid(String productid) { + this.productid = productid; + } + + public String getLuminaireuniqueid() { return luminaireuniqueid; } @@ -86,9 +105,11 @@ public class DeviceResponse { response.setName(device.getName()); response.setUniqueid(device.getUniqueid()); response.setManufacturername("Philips"); - response.setType("Dimmable light"); - response.setModelid("LWB004"); - response.setSwversion("66012040"); + response.setType("Extended color light"); + response.setModelid("LCT010"); + response.setSwversion("1.15.2_r19181"); + response.setSwconfigid("F921C859"); + response.setProductid("Philips-LCT010-1-A19ECLv4"); response.setLuminaireuniqueid(null); return response; 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 f01e980..c3bcbac 100644 --- a/src/main/java/com/bwssystems/HABridge/api/hue/DeviceState.java +++ b/src/main/java/com/bwssystems/HABridge/api/hue/DeviceState.java @@ -1,6 +1,6 @@ package com.bwssystems.HABridge.api.hue; -// import java.util.ArrayList; +import java.util.ArrayList; import java.util.List; /** @@ -12,11 +12,12 @@ public class DeviceState { private int hue; private int sat; private String effect; + private List xy; private int ct; private String alert; private String colormode; private boolean reachable; - private List xy; + // private int transitiontime; public boolean isOn() { @@ -41,6 +42,7 @@ public class DeviceState { public void setHue(int hue) { this.hue = hue; + this.colormode = "hs"; } public int getSat() { @@ -49,6 +51,7 @@ public class DeviceState { public void setSat(int sat) { this.sat = sat; + this.colormode = "hs"; } public String getEffect() { @@ -65,6 +68,7 @@ public class DeviceState { public void setCt(int ct) { this.ct = ct; + this.colormode = "ct"; } public String getAlert() { @@ -97,6 +101,7 @@ public class DeviceState { public void setXy(List xy) { this.xy = xy; + this.colormode = "xy"; } // public int getTransitiontime() { // return transitiontime; @@ -109,11 +114,12 @@ public class DeviceState { public static DeviceState createDeviceState() { DeviceState newDeviceState = new DeviceState(); newDeviceState.fillIn(); -// newDeviceState.setColormode("none"); -// ArrayList doubleArray = new ArrayList(); -// doubleArray.add(new Double(0)); -// doubleArray.add(new Double(0)); -// newDeviceState.setXy(doubleArray); + newDeviceState.setColormode("ct"); + newDeviceState.setCt(200); + ArrayList doubleArray = new ArrayList(); + doubleArray.add(new Double(0)); + doubleArray.add(new Double(0)); + newDeviceState.setXy(doubleArray); return newDeviceState; } diff --git a/src/main/java/com/bwssystems/HABridge/dao/DeviceDescriptor.java b/src/main/java/com/bwssystems/HABridge/dao/DeviceDescriptor.java index 7480be7..26bfdec 100644 --- a/src/main/java/com/bwssystems/HABridge/dao/DeviceDescriptor.java +++ b/src/main/java/com/bwssystems/HABridge/dao/DeviceDescriptor.java @@ -38,6 +38,9 @@ public class DeviceDescriptor{ @SerializedName("onUrl") @Expose private String onUrl; + @SerializedName("colorUrl") + @Expose + private String colorUrl; @SerializedName("headers") @Expose private String headers; @@ -142,6 +145,14 @@ public class DeviceDescriptor{ this.onUrl = onUrl; } + public String getColorUrl() { + return colorUrl; + } + + public void setColorUrl(String colorUrl) { + this.colorUrl = colorUrl; + } + public String getId() { return id; } @@ -282,6 +293,9 @@ public class DeviceDescriptor{ if(this.offUrl != null && this.offUrl.contains(aType)) return true; + + if(this.colorUrl != null && this.colorUrl.contains(aType)) + return true; return false; } diff --git a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java index 038bdce..0718b00 100644 --- a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java +++ b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java @@ -467,16 +467,6 @@ public class HueMulator { notFirstChange = true; } - if (body.contains("\"ct\"")) { - if (notFirstChange) - responseString = responseString + ","; - responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/ct\":" + stateChanges.getCt() - + "}}"; - if (deviceState != null) - deviceState.setCt(stateChanges.getCt()); - notFirstChange = true; - } - if (body.contains("\"xy\"")) { if (notFirstChange) responseString = responseString + ","; @@ -485,36 +475,34 @@ public class HueMulator { if (deviceState != null) deviceState.setXy(stateChanges.getXy()); notFirstChange = true; - } - - if (body.contains("\"hue\"")) { + } else if (body.contains("\"ct\"")) { if (notFirstChange) responseString = responseString + ","; - responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/hue\":" + stateChanges.getHue() + responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/ct\":" + stateChanges.getCt() + "}}"; if (deviceState != null) - deviceState.setHue(stateChanges.getHue()); + deviceState.setCt(stateChanges.getCt()); notFirstChange = true; - } + } else { + if (body.contains("\"hue\"")) { + if (notFirstChange) + responseString = responseString + ","; + responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/hue\":" + stateChanges.getHue() + + "}}"; + if (deviceState != null) + deviceState.setHue(stateChanges.getHue()); + notFirstChange = true; + } - if (body.contains("\"sat\"")) { - if (notFirstChange) - responseString = responseString + ","; - responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/sat\":" + stateChanges.getSat() - + "}}"; - if (deviceState != null) - deviceState.setSat(stateChanges.getSat()); - notFirstChange = true; - } - - if (body.contains("\"ct_inc\"")) { - if (notFirstChange) - responseString = responseString + ","; - responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/ct_inc\":" - + stateChanges.getCt_inc() + "}}"; - if (deviceState != null) - deviceState.setCt(deviceState.getCt() + stateChanges.getCt_inc()); - notFirstChange = true; + if (body.contains("\"sat\"")) { + if (notFirstChange) + responseString = responseString + ","; + responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/sat\":" + stateChanges.getSat() + + "}}"; + if (deviceState != null) + deviceState.setSat(stateChanges.getSat()); + notFirstChange = true; + } } if (body.contains("\"xy_inc\"")) { @@ -525,26 +513,34 @@ public class HueMulator { if (deviceState != null) deviceState.setXy(stateChanges.getXy()); notFirstChange = true; - } - - if (body.contains("\"hue_inc\"")) { + } else if (body.contains("\"ct_inc\"")) { if (notFirstChange) responseString = responseString + ","; - responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/hue_inc\":" - + stateChanges.getHue_inc() + "}}"; + responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/ct_inc\":" + + stateChanges.getCt_inc() + "}}"; if (deviceState != null) - deviceState.setHue(deviceState.getHue() + stateChanges.getHue_inc()); + deviceState.setCt(deviceState.getCt() + stateChanges.getCt_inc()); notFirstChange = true; - } + } else { + if (body.contains("\"hue_inc\"")) { + if (notFirstChange) + responseString = responseString + ","; + responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/hue_inc\":" + + stateChanges.getHue_inc() + "}}"; + if (deviceState != null) + deviceState.setHue(deviceState.getHue() + stateChanges.getHue_inc()); + notFirstChange = true; + } - if (body.contains("\"sat_inc\"")) { - if (notFirstChange) - responseString = responseString + ","; - responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/sat_inc\":" - + stateChanges.getSat_inc() + "}}"; - if (deviceState != null) - deviceState.setSat(deviceState.getSat() + stateChanges.getSat_inc()); - notFirstChange = true; + if (body.contains("\"sat_inc\"")) { + if (notFirstChange) + responseString = responseString + ","; + responseString = responseString + "{\"success\":{\"/lights/" + lightId + "/state/sat_inc\":" + + stateChanges.getSat_inc() + "}}"; + if (deviceState != null) + deviceState.setSat(deviceState.getSat() + stateChanges.getSat_inc()); + notFirstChange = true; + } } if (body.contains("\"effect\"")) { @@ -931,7 +927,9 @@ public class HueMulator { if (url == null || url.length() == 0) url = device.getOnUrl(); } else { - if (theStateChanges.isOn()) { + if (body.contains("\"xy\"") || body.contains("\"ct\"") || body.contains("\"hue\"")) { + url = device.getColorUrl(); + } else if (theStateChanges.isOn()) { url = device.getOnUrl(); } else if (!theStateChanges.isOn()) { url = device.getOffUrl(); diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js index 58fa27f..4bf6dc1 100644 --- a/src/main/resources/public/scripts/app.js +++ b/src/main/resources/public/scripts/app.js @@ -410,6 +410,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n if(device.offUrl !== undefined && device.offUrl !== null && device.offUrl.indexOf(aType) >= 0) return true; + + if(device.colorUrl !== undefined && device.colorUrl !== null && device.colorUrl.indexOf(aType) >= 0) + return true; return false; @@ -1185,17 +1188,20 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n return formattedItem; }; - this.buildUrls = function (onpayload, dimpayload, offpayload, isObject, anId, deviceName, deviceTarget, deviceType, deviceMapType, count, delay) { + this.buildUrls = function (onpayload, dimpayload, offpayload, colorpayload, isObject, anId, deviceName, deviceTarget, deviceType, deviceMapType, count, delay) { var currentOn = ""; var currentDim = ""; var currentOff = ""; + var currentColor = ""; if (self.state.device !== undefined && self.state.device !== null) { if (self.state.device.onUrl !== undefined && self.state.device.onUrl !== null&& self.state.device.onUrl !== "") currentOn = self.state.device.onUrl; if (self.state.device.dimUrl !== undefined && self.state.device.dimUrl !== null && self.state.device.dimUrl !== "") currentDim = self.state.device.dimUrl; - if (self.state.device.offUrl !== undefined && self.state.device.offnUrl !== null && self.state.device.offnUrl !== "") + if (self.state.device.offUrl !== undefined && self.state.device.offUrl !== null && self.state.device.offUrl !== "") currentOff = self.state.device.offUrl; + if (self.state.device.colorUrl !== undefined && self.state.device.colorUrl !== null && self.state.device.colorUrl !== "") + currentColor = self.state.device.colorUrl; } if (self.state.device !== undefined && self.state.device !== null && self.state.device.mapType !== undefined && self.state.device.mapType !== null && self.state.device.mapType !== "") { self.state.device.mapId = self.state.device.mapId + "-" + anId; @@ -1210,6 +1216,9 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n if (offpayload !== undefined && offpayload !== null && offpayload !== "") { self.state.device.offUrl = self.formatUrlItem(currentOff); } + if (colorpayload !== undefined && colorpayload !== null && colorpayload !== "") { + self.state.device.colorUrl = self.formatUrlItem(currentColor); + } } else if (self.state.device === undefined || self.state.device === null || self.state.device.mapType === undefined || self.state.device.mapType === null || self.state.device.mapType === "") { this.clearDevice(); self.state.device.deviceType = deviceType; @@ -1223,6 +1232,8 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n self.state.device.onUrl = "[{\"item\":"; if (offpayload !== undefined && offpayload !== null && offpayload !== "") self.state.device.offUrl = "[{\"item\":"; + if (colorpayload !== undefined && colorpayload !== null && colorpayload !== "") + self.state.device.colorUrl = "[{\"item\":"; } if (isObject) { @@ -1232,6 +1243,8 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n self.state.device.onUrl = self.state.device.onUrl + onpayload; if (offpayload !== undefined && offpayload !== null && offpayload !== "") self.state.device.offUrl = self.state.device.offUrl + offpayload; + if (colorpayload !== undefined && colorpayload !== null && colorpayload !== "") + self.state.device.colorUrl = self.state.device.colorUrl + colorpayload; } else { if (dimpayload !== undefined && dimpayload !== null && dimpayload !== "") @@ -1240,6 +1253,8 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n self.state.device.onUrl = self.state.device.onUrl + "\"" + onpayload + "\""; if (offpayload !== undefined && offpayload !== null && offpayload !== "") self.state.device.offUrl = self.state.device.offUrl + "\"" + offpayload + "\""; + if (colorpayload !== undefined && colorpayload !== null && colorpayload !== "") + self.state.device.colorUrl = self.state.device.colorUrl + "\"" + colorpayload + "\""; } if (count !== undefined && count !== null && count !== "") { @@ -1249,6 +1264,8 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n self.state.device.onUrl = self.state.device.onUrl + ",\"count\":\"" + count; if (offpayload !== undefined && offpayload !== null && offpayload !== "") self.state.device.offUrl = self.state.device.offUrl + ",\"count\":\"" + count; + if (colorpayload !== undefined && colorpayload !== null && colorpayload !== "") + self.state.device.colorUrl = self.state.device.colorUrl + ",\"count\":\"" + count; } if (delay !== undefined && delay !== null && delay !== "") { if (dimpayload !== undefined && dimpayload !== null && dimpayload !== "") @@ -1257,6 +1274,8 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n self.state.device.onUrl = self.state.device.onUrl + ",\"delay\":\"" + delay; if (offpayload !== undefined && offpayload !== null && offpayload !== "") self.state.device.offUrl = self.state.device.offUrl + ",\"delay\":\"" + delay; + if (colorpayload !== undefined && colorpayload !== null && colorpayload !== "") + self.state.device.colorUrl = self.state.device.colorUrl + ",\"delay\":\"" + delay; } if (dimpayload !== undefined && dimpayload !== null && dimpayload !== "") self.state.device.dimUrl = self.state.device.dimUrl + ",\"type\":\"" + deviceMapType + "\"}]"; @@ -1264,6 +1283,8 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n self.state.device.onUrl = self.state.device.onUrl + ",\"type\":\"" + deviceMapType + "\"}]"; if (offpayload !== undefined && offpayload !== null && offpayload !== "") self.state.device.offUrl = self.state.device.offUrl + ",\"type\":\"" + deviceMapType + "\"}]"; + if (colorpayload !== undefined && colorpayload !== null && colorpayload !== "") + self.state.device.colorUrl = self.state.device.colorUrl + ",\"type\":\"" + deviceMapType + "\"}]"; }; }); @@ -1639,7 +1660,7 @@ app.controller('ViewingController', function ($scope, $location, bridgeService, var dialogNeeded = false; if ((type === "on" && device.onUrl !== undefined && bridgeService.aContainsB(device.onUrl, "${intensity")) || (type === "off" && device.offUrl !== undefined && bridgeService.aContainsB(device.offUrl, "${intensity")) || - (type === "dim" && device.dimUrl !== undefined)) { + (type === "dim" && device.dimUrl !== undefined) || (type === "color" && device.colorUrl !== undefined)) { $scope.bridge.device = device; $scope.bridge.type = type; ngDialog.open({ @@ -1783,10 +1804,10 @@ app.controller('VeraController', function ($scope, $location, bridgeService, ngD + "/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=" + veradevice.id; offpayload = "http://" + veradevice.veraaddress + ":" + $scope.vera.port - + "/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=" - + veradevice.id; - - bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, veradevice.id, veradevice.name, veradevice.veraname, "switch", "veraDevice", null, null); + + "/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=" + + veradevice.id; + + bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, false, veradevice.id, veradevice.name, veradevice.veraname, "switch", "veraDevice", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -1802,7 +1823,7 @@ app.controller('VeraController', function ($scope, $location, bridgeService, ngD + "/data_request?id=action&output_format=json&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=" + verascene.id; - bridgeService.buildUrls(onpayload, null, offpayload, false, verascene.id, verascene.name, verascene.veraname, "scene", "veraScene", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, false, verascene.id, verascene.name, verascene.veraname, "scene", "veraScene", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); $location.path('/editdevice'); @@ -1824,6 +1845,7 @@ app.controller('VeraController', function ($scope, $location, bridgeService, ngD onUrl: $scope.device.onUrl, dimUrl: $scope.device.dimUrl, offUrl: $scope.device.offUrl, + colorUrl: $scope.device.colorUrl, headers: $scope.device.headers, httpVerb: $scope.device.httpVerb, contentType: $scope.device.contentType, @@ -1924,7 +1946,7 @@ app.controller('HarmonyController', function ($scope, $location, bridgeService, onpayload = "{\"name\":\"" + harmonyactivity.activity.id + "\",\"hub\":\"" + harmonyactivity.hub + "\"}"; offpayload = "{\"name\":\"-1\",\"hub\":\"" + harmonyactivity.hub + "\"}"; - bridgeService.buildUrls(onpayload, null, offpayload, true, harmonyactivity.activity.id, harmonyactivity.activity.label, harmonyactivity.hub, "activity", "harmonyActivity", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, true, harmonyactivity.activity.id, harmonyactivity.activity.label, harmonyactivity.hub, "activity", "harmonyActivity", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); $location.path('/editdevice'); @@ -1943,7 +1965,7 @@ app.controller('HarmonyController', function ($scope, $location, bridgeService, postCmd = "\"}"; offpayload = "{\"device\":\"" + harmonydevice.device.id + "\",\"button\":\"" + actionOff.command + "\",\"hub\":\"" + harmonydevice.hub + postCmd; - bridgeService.buildUrls(onpayload, null, offpayload, true, actionOn.command, harmonydevice.device.label, harmonydevice.hub, "button", "harmonyButton", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, true, actionOn.command, harmonydevice.device.label, harmonydevice.hub, "button", "harmonyButton", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); $location.path('/editdevice'); @@ -1987,7 +2009,7 @@ app.controller('NestController', function ($scope, $location, bridgeService, ngD $scope.buildNestHomeUrls = function (nestitem) { onpayload = "{\"name\":\"" + nestitem.id + "\",\"away\":false,\"control\":\"status\"}"; offpayload = "{\"name\":\"" + nestitem.id + "\",\"away\":true,\"control\":\"status\"}"; - bridgeService.buildUrls(onpayload, null, offpayload, true, nestitem.id, nestitem.name, nestitem.name, "home", "nestHomeAway", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, true, nestitem.id, nestitem.name, nestitem.name, "home", "nestHomeAway", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); $location.path('/editdevice'); @@ -1997,7 +2019,7 @@ app.controller('NestController', function ($scope, $location, bridgeService, ngD onpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"temp\",\"temp\":\"${intensity.percent}\"}"; dimpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"temp\",\"temp\":\"${intensity.percent}\"}"; offpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"off\"}"; - bridgeService.buildUrls(onpayload, dimpayload, offpayload, true, nestitem.id + "-SetTemp", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Temperature", nestitem.location, "thermo", "nestThermoSet", null, null); + bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, true, nestitem.id + "-SetTemp", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Temperature", nestitem.location, "thermo", "nestThermoSet", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); $location.path('/editdevice'); @@ -2007,7 +2029,7 @@ app.controller('NestController', function ($scope, $location, bridgeService, ngD onpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"heat\"}"; dimpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"temp\",\"temp\":\"${intensity.percent}\"}"; offpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"off\"}"; - bridgeService.buildUrls(onpayload, dimpayload, offpayload, true, nestitem.id + "-SetHeat", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Heat", nestitem.location, "thermo", "nestThermoSet", null, null); + bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, true, nestitem.id + "-SetHeat", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Heat", nestitem.location, "thermo", "nestThermoSet", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); $location.path('/editdevice'); @@ -2017,7 +2039,7 @@ app.controller('NestController', function ($scope, $location, bridgeService, ngD onpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"cool\"}"; dimpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"temp\",\"temp\":\"${intensity.percent}\"}"; offpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"off\"}"; - bridgeService.buildUrls(onpayload,dimpayload, offpayload, true, nestitem.id + "-SetCool", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Cool", nestitem.location, "thermo", "nestThermoSet", null, null); + bridgeService.buildUrls(onpayload,dimpayload, offpayload, null, true, nestitem.id + "-SetCool", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Cool", nestitem.location, "thermo", "nestThermoSet", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); $location.path('/editdevice'); @@ -2026,7 +2048,7 @@ app.controller('NestController', function ($scope, $location, bridgeService, ngD $scope.buildNestRangeUrls = function (nestitem) { onpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"range\"}"; offpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"off\"}"; - bridgeService.buildUrls(onpayload, null, offpayload, true, nestitem.id + "-SetRange", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Range", nestitem.location, "thermo", "nestThermoSet", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, true, nestitem.id + "-SetRange", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Range", nestitem.location, "thermo", "nestThermoSet", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); $location.path('/editdevice'); @@ -2035,7 +2057,7 @@ app.controller('NestController', function ($scope, $location, bridgeService, ngD $scope.buildNestOffUrls = function (nestitem) { onpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"range\"}"; offpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"off\"}"; - bridgeService.buildUrls(onpayload, null, offpayload, true, nestitem.id + "-TurnOff", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Thermostat", nestitem.location, "thermo", "nestThermoSet", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, true, nestitem.id + "-TurnOff", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Thermostat", nestitem.location, "thermo", "nestThermoSet", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); $location.path('/editdevice'); @@ -2044,7 +2066,7 @@ app.controller('NestController', function ($scope, $location, bridgeService, ngD $scope.buildNestFanUrls = function (nestitem) { onpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"fan-on\"}"; offpayload = "{\"name\":\"" + nestitem.id + "\",\"control\":\"fan-auto\"}"; - bridgeService.buildUrls(onpayload, null, offpayload, true, nestitem.id + "-SetFan", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Fan", nestitem.location, "thermo", "nestThermoSet", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, true, nestitem.id + "-SetFan", nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Fan", nestitem.location, "thermo", "nestThermoSet", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); $location.path('/editdevice'); @@ -2090,7 +2112,7 @@ app.controller('HueController', function ($scope, $location, bridgeService, ngDi $scope.buildDeviceUrls = function (huedevice, buildonly) { onpayload = "{\"ipAddress\":\"" + huedevice.hueaddress + "\",\"deviceId\":\"" + huedevice.huedeviceid +"\",\"hueName\":\"" + huedevice.huename + "\"}"; offpayload = "{\"ipAddress\":\"" + huedevice.hueaddress + "\",\"deviceId\":\"" + huedevice.huedeviceid +"\",\"hueName\":\"" + huedevice.huename + "\"}"; - bridgeService.buildUrls(onpayload, null, offpayload, true, huedevice.device.uniqueid, huedevice.device.name, huedevice.huename, "passthru", "hueDevice", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, true, huedevice.device.uniqueid, huedevice.device.name, huedevice.huename, "passthru", "hueDevice", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2114,6 +2136,7 @@ app.controller('HueController', function ($scope, $location, bridgeService, ngDi onUrl: $scope.device.onUrl, dimUrl: $scope.device.dimUrl, offUrl: $scope.device.offUrl, + colorUrl: $scope.device.colorUrl, headers: $scope.device.headers, httpVerb: $scope.device.httpVerb, contentType: $scope.device.contentType, @@ -2257,7 +2280,7 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi + preOffCmd + nameCmd + haldevice.haldevicename.replaceAll(" ", "%20"); - bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name, haldevice.haldevicename, haldevice.haladdress.name, aDeviceType, "halDevice", null, null); + bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name, haldevice.haldevicename, haldevice.haladdress.name, aDeviceType, "halDevice", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2271,7 +2294,7 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi onpayload = "http://" + haldevice.haladdress.ip + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOn.DeviceName.replaceAll(" ", "%20"); offpayload = "http://" + haldevice.haladdress.ip + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOff.DeviceName.replaceAll(" ", "%20"); - bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-" + actionOn.DeviceName, haldevice.haldevicename, haldevice.haladdress.name, "button", "halButton", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-" + actionOn.DeviceName, haldevice.haldevicename, haldevice.haladdress.name, "button", "halButton", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2282,7 +2305,7 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi $scope.buildHALHomeUrls = function (haldevice, buildonly) { onpayload = "http://" + haldevice.haladdress.ip + "/ModeService!ModeCmd=Set!ModeName=Home"; offpayload = "http://" + haldevice.haladdress.ip + "/ModeService!ModeCmd=Set!ModeName=Away"; - bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-HomeAway", haldevice.haldevicename, haldevice.haladdress.name, "home", "halHome", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-HomeAway", haldevice.haldevicename, haldevice.haladdress.name, "home", "halHome", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2303,7 +2326,7 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Off"; - bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetHeat", haldevice.haldevicename + " Heat", haldevice.haladdress.name, "thermo", "halThermoSet", null, null); + bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetHeat", haldevice.haldevicename + " Heat", haldevice.haladdress.name, "thermo", "halThermoSet", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2324,7 +2347,7 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Off"; - bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetCool", haldevice.haldevicename + " Cool", haldevice.haladdress.name, "thermo", "halThermoSet", null, null); + bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetCool", haldevice.haldevicename + " Cool", haldevice.haladdress.name, "thermo", "halThermoSet", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2341,7 +2364,7 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Off"; - bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetAuto", haldevice.haldevicename + " Auto", haldevice.haladdress.name, "thermo", "halThermoSet", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetAuto", haldevice.haldevicename + " Auto", haldevice.haladdress.name, "thermo", "halThermoSet", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2358,7 +2381,7 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!HVACMode=Off"; - bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-TurnOff", haldevice.haldevicename + " Thermostat", haldevice.haladdress.name, "thermo", "halThermoSet", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-TurnOff", haldevice.haldevicename + " Thermostat", haldevice.haladdress.name, "thermo", "halThermoSet", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2375,7 +2398,7 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi + "/HVACService!HVACCmd=Set!HVACName=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!FanMode=Auto"; - bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetFan", haldevice.haldevicename + " Fan", haldevice.haladdress.name, "thermo", "halThermoSet", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetFan", haldevice.haldevicename + " Fan", haldevice.haladdress.name, "thermo", "halThermoSet", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2404,6 +2427,7 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi onUrl: $scope.device.onUrl, dimUrl: $scope.device.dimUrl, offUrl: $scope.device.offUrl, + colorUrl: $scope.device.colorUrl, headers: $scope.device.headers, httpVerb: $scope.device.httpVerb, contentType: $scope.device.contentType, @@ -2499,7 +2523,7 @@ app.controller('MQTTController', function ($scope, $location, bridgeService, ngD onpayload = "{\"clientId\":\"" + mqttbroker.clientId + "\",\"topic\":\"" + mqtttopic + "\",\"message\":\"" + mqttmessage + "\",\"qos\":\"" + mqttqos + "\",\"retain\":\"" + mqttretain + "\"}"; offpayload = "{\"clientId\":\"" + mqttbroker.clientId + "\",\"topic\":\"" + mqtttopic + "\",\"message\":\"" + mqttmessage + "\",\"qos\":\"" + mqttqos + "\",\"retain\":\"" + mqttretain + "\"}"; - bridgeService.buildUrls(onpayload, null, offpayload, true, mqttbroker.clientId + "-" + mqtttopic, mqttbroker.clientId + mqtttopic, mqttbroker.clientId, "mqtt", "mqttMessage", null, null); + bridgeService.buildUrls(onpayload, null, offpayload, null, true, mqttbroker.clientId + "-" + mqtttopic, mqttbroker.clientId + mqtttopic, mqttbroker.clientId, "mqtt", "mqttMessage", null, null); $scope.device = bridgeService.state.device; bridgeService.editNewDevice($scope.device); $location.path('/editdevice'); @@ -2551,7 +2575,7 @@ app.controller('HassController', function ($scope, $location, bridgeService, ngD dimpayload = "{\"entityId\":\"" + hassdevice.deviceState.entity_id + "\",\"hassName\":\"" + hassdevice.hassname + "\",\"state\":\"on\"}"; offpayload = "{\"entityId\":\"" + hassdevice.deviceState.entity_id + "\",\"hassName\":\"" + hassdevice.hassname + "\",\"state\":\"off\"}"; - bridgeService.buildUrls(onpayload, dimpayload, offpayload, true, hassdevice.hassname + "-" + hassdevice.deviceState.entity_id, hassdevice.deviceState.entity_id, hassdevice.hassname, hassdevice.domain, "hassDevice", null, null); + bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, true, hassdevice.hassname + "-" + hassdevice.deviceState.entity_id, hassdevice.deviceState.entity_id, hassdevice.hassname, hassdevice.domain, "hassDevice", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2575,6 +2599,7 @@ app.controller('HassController', function ($scope, $location, bridgeService, ngD onUrl: $scope.device.onUrl, dimUrl: $scope.device.dimUrl, offUrl: $scope.device.offUrl, + colorUrl: $scope.device.colorUrl, headers: $scope.device.headers, httpVerb: $scope.device.httpVerb, contentType: $scope.device.contentType, @@ -2706,7 +2731,7 @@ app.controller('DomoticzController', function ($scope, $location, bridgeService, + preCmd + domoticzdevice.idx + postOffCmd; - bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, domoticzdevice.devicename + "-" + domoticzdevice.domoticzname, domoticzdevice.devicename, domoticzdevice.domoticzname, aDeviceType, "domoticzDevice", null, null); + bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, false, domoticzdevice.devicename + "-" + domoticzdevice.domoticzname, domoticzdevice.devicename, domoticzdevice.domoticzname, aDeviceType, "domoticzDevice", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2730,6 +2755,7 @@ app.controller('DomoticzController', function ($scope, $location, bridgeService, onUrl: $scope.device.onUrl, dimUrl: $scope.device.dimUrl, offUrl: $scope.device.offUrl, + colorUrl: $scope.device.colorUrl, headers: $scope.device.headers, httpVerb: $scope.device.httpVerb, contentType: $scope.device.contentType, @@ -2828,7 +2854,7 @@ app.controller('LifxController', function ($scope, $location, bridgeService, ngD dimpayload = angular.toJson(lifxdevice); onpayload = angular.toJson(lifxdevice); offpayload = angular.toJson(lifxdevice); - bridgeService.buildUrls(onpayload, dimpayload, offpayload, true, lifxdevice.name, lifxdevice.name, lifxdevice.name, null, "lifxDevice", null, null); + bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, true, lifxdevice.name, lifxdevice.name, lifxdevice.name, null, "lifxDevice", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2852,6 +2878,7 @@ app.controller('LifxController', function ($scope, $location, bridgeService, ngD onUrl: $scope.device.onUrl, dimUrl: $scope.device.dimUrl, offUrl: $scope.device.offUrl, + colorUrl: $scope.device.colorUrl, headers: $scope.device.headers, httpVerb: $scope.device.httpVerb, contentType: $scope.device.contentType, @@ -2955,7 +2982,7 @@ app.controller('SomfyController', function ($scope, $location, bridgeService, ng onpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"open\",\"parameters\":[]}]}]}"; offpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"close\",\"parameters\":[]}]}]}"; - bridgeService.buildUrls(onpayload, dimpayload, offpayload, true, somfydevice.id, somfydevice.name, somfydevice.somfyname, "switch", "somfyDevice", null, null); + bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, true, somfydevice.id, somfydevice.name, somfydevice.somfyname, "switch", "somfyDevice", null, null); $scope.device = bridgeService.state.device; if (!buildonly) { bridgeService.editNewDevice($scope.device); @@ -2980,6 +3007,7 @@ app.controller('SomfyController', function ($scope, $location, bridgeService, ng onUrl: $scope.device.onUrl, dimUrl: $scope.device.dimUrl, offUrl: $scope.device.offUrl, + colorUrl: $scope.device.colorUrl, headers: $scope.device.headers, httpVerb: $scope.device.httpVerb, contentType: $scope.device.contentType, @@ -3065,18 +3093,35 @@ app.controller('EditController', function ($scope, $location, bridgeService) { $scope.onDevices = null; $scope.dimDevices = null; $scope.offDevices = null; + $scope.colorDevices = null; + $scope.showUrls = false; + $scope.onUrl = null; + $scope.dimUrl = null; + $scope.offUrl = null; + $scope.colorUrl = null; if ($scope.device !== undefined && $scope.device.name !== undefined) { - if($scope.bridge.device.onUrl !== undefined) + if($scope.bridge.device.onUrl !== undefined) { $scope.onDevices = bridgeService.getCallObjects($scope.bridge.device.onUrl); - if($scope.bridge.device.dimUrl !== undefined) + $scope.onUrl = $scope.bridge.device.onUrl.split("},").join("},\n"); + } + if($scope.bridge.device.dimUrl !== undefined) { $scope.dimDevices = bridgeService.getCallObjects($scope.bridge.device.dimUrl); - if($scope.bridge.device.offUrl !== undefined) + $scope.dimUrl = $scope.bridge.device.dimUrl.split("},").join("},\n"); + } + if($scope.bridge.device.offUrl !== undefined) { $scope.offDevices = bridgeService.getCallObjects($scope.bridge.device.offUrl); + $scope.offUrl = $scope.bridge.device.offUrl.split("},").join("},\n"); + } + if($scope.bridge.device.colorUrl !== undefined) { + $scope.colorDevices = bridgeService.getCallObjects($scope.bridge.device.colorUrl); + $scope.colorUrl = $scope.bridge.device.colorUrl.split("},").join("},\n"); + } } $scope.newOnItem = {}; $scope.newDimItem = {}; $scope.newOffItem = {}; + $scope.newColorItem = {}; $scope.mapTypeSelected = bridgeService.getMapType($scope.device.mapType); $scope.device_dim_control = ""; $scope.imgButtonsUrl = "glyphicon glyphicon-plus"; @@ -3087,9 +3132,16 @@ app.controller('EditController', function ($scope, $location, bridgeService) { $scope.onDevices = null; $scope.dimDevices = null; $scope.offDevices = null; + $scope.colorDevices = null; + $scope.showUrls = false; + $scope.onUrl = null; + $scope.dimUrl = null; + $scope.offUrl = null; + $scope.colorUrl = null; $scope.newOnItem = {}; $scope.newDimItem = {}; $scope.newOffItem = {}; + $scope.newColorItem = {}; $scope.device = bridgeService.state.device; $scope.mapTypeSelected = null; }; @@ -3116,12 +3168,22 @@ app.controller('EditController', function ($scope, $location, bridgeService) { else $scope.device.mapType = null; - if ($scope.onDevices !== null) - $scope.device.onUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.onDevices)); - if ($scope.dimDevices !== null) - $scope.device.dimUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.dimDevices)); - if ($scope.offDevices !== null) - $scope.device.offUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.offDevices)); + if ($scope.showUrls) { + $scope.device.onUrl = ($scope.onUrl == undefined || $scope.onUrl == null || $scope.onUrl == "") ? null : $scope.onUrl.replace(/\r?\n|\r/g,""); + $scope.device.dimUrl = ($scope.dimUrl == undefined || $scope.dimUrl == null || $scope.dimUrl == "") ? null : $scope.dimUrl.replace(/\r?\n|\r/g,""); + $scope.device.offUrl = ($scope.offUrl == undefined || $scope.offUrl == null || $scope.offUrl == "") ? null : $scope.offUrl.replace(/\r?\n|\r/g,""); + $scope.device.colorUrl = ($scope.colorUrl == undefined || $scope.colorUrl == null || $scope.colorUrl == "") ? null : $scope.colorUrl.replace(/\r?\n|\r/g,""); + } else { + if ($scope.onDevices !== null) + $scope.device.onUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.onDevices)); + if ($scope.dimDevices !== null) + $scope.device.dimUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.dimDevices)); + if ($scope.offDevices !== null) + $scope.device.offUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.offDevices)); + if ($scope.colorDevices !== null) + $scope.device.colorUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.colorDevices)); + } + bridgeService.addDevice($scope.device).then( function () { @@ -3148,7 +3210,7 @@ app.controller('EditController', function ($scope, $location, bridgeService) { }; $scope.removeItemOn = function (anItem) { for(var i = $scope.onDevices.length - 1; i >= 0; i--) { - if($scope.onDevices[i].item === anItem.item && $scope.onDevices[i].type === anItem.type) { + if($scope.onDevices[i] === anItem) { $scope.onDevices.splice(i, 1); } } @@ -3165,8 +3227,8 @@ app.controller('EditController', function ($scope, $location, bridgeService) { }; $scope.removeItemDim = function (anItem) { for(var i = $scope.dimDevices.length - 1; i >= 0; i--) { - if($scope.dimDevices[i].item === anItem.item && $scope.dimDevices[i].type === anItem.type) { - $scope.dimDevices.splice(i, 1); + if($scope.dimDevices[i] === anItem) { + $scope.dimDevices.splice(i, 1); } } }; @@ -3182,11 +3244,30 @@ app.controller('EditController', function ($scope, $location, bridgeService) { }; $scope.removeItemOff = function (anItem) { for(var i = $scope.offDevices.length - 1; i >= 0; i--) { - if($scope.offDevices[i].item === anItem.item && $scope.offDevices[i].type === anItem.type) { + if($scope.offDevices[i] === anItem) { $scope.offDevices.splice(i, 1); } } }; + + $scope.addItemColor = function (anItem) { + if (anItem.item === undefined || anItem.item === null || anItem.item === "") + return; + var newitem = { item: anItem.item, type: anItem.type, delay: anItem.delay, count: anItem.count, filterIPs: anItem.filterIPs, httpVerb: anItem.httpVerb, httpBody: anItem.httpBody, httpHeaders: anItem.httpHeaders, contentType: anItem.contentType }; + if ($scope.colorDevices === null) + $scope.colorDevices = []; + $scope.colorDevices.push(newitem); + $scope.newColorItem = {}; + }; + $scope.removeItemColor = function (anItem) { + for(var i = $scope.colorDevices.length - 1; i >= 0; i--) { + if($scope.colorDevices[i] === anItem) { + $scope.colorDevices.splice(i, 1); + } + } + }; + + $scope.toggleButtons = function () { $scope.buttonsVisible = !$scope.buttonsVisible; if($scope.buttonsVisible) @@ -3195,6 +3276,22 @@ app.controller('EditController', function ($scope, $location, bridgeService) { $scope.imgButtonsUrl = "glyphicon glyphicon-plus"; }; + $scope.changeEditmode = function () { + // copy local changes over to other edit mode + if ($scope.showUrls) { + $scope.onDevices = ($scope.onUrl == undefined || $scope.onUrl == null || $scope.onUrl == "") ? null : bridgeService.getCallObjects($scope.onUrl.replace(/\r?\n|\r/g,"")); + $scope.dimDevices = ($scope.dimUrl == undefined || $scope.dimUrl == null || $scope.dimUrl == "") ? null : bridgeService.getCallObjects($scope.dimUrl.replace(/\r?\n|\r/g,"")); + $scope.offDevices = ($scope.offUrl == undefined || $scope.offUrl == null || $scope.offUrl == "") ? null : bridgeService.getCallObjects($scope.offUrl.replace(/\r?\n|\r/g,"")); + $scope.colorDevices = ($scope.colorUrl == undefined || $scope.colorUrl == null || $scope.colorUrl == "") ? null : bridgeService.getCallObjects($scope.colorUrl.replace(/\r?\n|\r/g,"")); + } else { + $scope.onUrl = ($scope.onDevices !== null) ? angular.toJson(bridgeService.updateCallObjectsType($scope.onDevices)).split("},").join("},\n") : null; + $scope.dimUrl = ($scope.dimDevices !== null) ? angular.toJson(bridgeService.updateCallObjectsType($scope.dimDevices)).split("},").join("},\n") : null; + $scope.offUrl = ($scope.offDevices !== null) ? angular.toJson(bridgeService.updateCallObjectsType($scope.offDevices)).split("},").join("},\n") : null; + $scope.colorUrl = ($scope.colorDevices !== null) ? angular.toJson(bridgeService.updateCallObjectsType($scope.colorDevices)).split("},").join("},\n") : null; + } + $scope.showUrls = !$scope.showUrls; + }; + }); app.filter('configuredVeraDevices', function (bridgeService) { diff --git a/src/main/resources/public/views/editdevice.html b/src/main/resources/public/views/editdevice.html index ae1439d..fbd2f86 100644 --- a/src/main/resources/public/views/editdevice.html +++ b/src/main/resources/public/views/editdevice.html @@ -56,6 +56,7 @@ ng-click="editDevice(false)">Update Bridge Device +

@@ -147,7 +148,14 @@ - + + + + + + + - + @@ -171,20 +179,20 @@
- + - - - --> + -
-
- - - - --> + -
@@ -159,7 +167,7 @@ Target Item Delay CountFilter IPs Http Verb Http Body Http Headers
@@ -220,24 +228,24 @@
@@ -274,7 +282,14 @@
- + + + + + + + @@ -286,7 +301,7 @@ Target Item Delay Count - Filter IPs + Http Verb Http Body Http Headers @@ -297,22 +312,22 @@
- - - - - - + @@ -324,7 +339,7 @@ - @@ -348,24 +363,24 @@
- - - - - - + @@ -377,7 +392,7 @@ - @@ -402,7 +417,14 @@ - + + + + + + + @@ -414,7 +436,7 @@ Target Item Delay Count - Filter IPs + Http Verb Http Body Http Headers @@ -425,22 +447,22 @@
- - - - - - + @@ -452,7 +474,7 @@ - @@ -476,24 +498,24 @@
- - - - - - + @@ -505,7 +527,7 @@ - @@ -530,6 +552,140 @@ + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
+
+ + + + + + + + + + + +
TypeTarget ItemDelayCountHttp VerbHttp BodyHttp HeadersContent TypeManage
+
+