diff --git a/README.md b/README.md index 12144041..ca12d25c 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ java -jar -Dupnp.config.address=A.B.C.D -Dvera.address=E.F.G.H -Dharmony.addres ## Available Arguments ### -Dupnp.config.address=`` The server defaults to the first available address on the host if this is not given. This default may NOT be the correct IP that is your public IP for your host on the network. It is best to set this parameter to not have discovery issues. Replace the -Dupnp.config.address=`` value with the server ipv4 address you would like to use as the address that any upnp device will call after discovery. -### -Dvera.address=`` -The argument for the vera address should be given as it the system does not have a way to find the address. Supply -Dvera.address=X.Y.Z.A on the command line to provide it. If a vera is not used, do not set it. +### -Dvera.address=`` | `<{devices:[{name:avera,ip:x.y.w.z},{name:anothervera,ip:a.b.c.d}]}>` +The argument for the vera address should be given as it the system does not have a way to find the address. Supply -Dvera.address=X.Y.Z.A on the command line to provide it. If a vera is not used, do not set it. To provide multiple veras, use the json style notation outlined above to provide the list. This argument is backwards compatible. ### -Dserver.port=`` The server defaults to running on port 8080. If you're already running a server (like openHAB) on 8080, -Dserver.port=`` on the command line. ### -Dupnp.device.db=`` @@ -306,7 +306,9 @@ comment | string | Comment configured with device. Not always present. "status":"0", "level":"0", "state":"-1", - "comment":"" + "comment":"", + "veraname":"default", + "veraddress":"192.168.1.2" }, { "name":"Couch Right Lamp", @@ -320,6 +322,8 @@ comment | string | Comment configured with device. Not always present. "level":"0", "state":"-1", "comment":"" + "veraname":"default", + "veraddress":"192.168.1.2" }] ``` ### Get Vera Scenes @@ -340,12 +344,16 @@ room | string | Room name assigned to scene. "name":"AccentLightsOff", "id":"27", "room":"no room" + "veraname":"default", + "veraddress":"192.168.1.2" }, { "active":"0", "name":"AccentLightsOn", "id":"26", "room":"no room" + "veraname":"default", + "veraddress":"192.168.1.2" }] ``` ### Get Harmony Activities diff --git a/pom.xml b/pom.xml index 3390b210..b53d0e94 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.bwssystems.HABridge ha-bridge - 1.3.1c + 1.3.5 jar HA Bridge diff --git a/src/main/java/com/bwssystems/HABridge/BridgeSettings.java b/src/main/java/com/bwssystems/HABridge/BridgeSettings.java index 41d0d8d2..c9c10e75 100644 --- a/src/main/java/com/bwssystems/HABridge/BridgeSettings.java +++ b/src/main/java/com/bwssystems/HABridge/BridgeSettings.java @@ -7,7 +7,7 @@ public class BridgeSettings { private String serverport; private String upnpresponseport; private String upnpdevicedb; - private String veraaddress; + private IpList veraaddress; private IpList harmonyaddress; private String harmonyuser; private String harmonypwd; @@ -43,10 +43,10 @@ public String getUpnpDeviceDb() { public void setUpnpDeviceDb(String upnpDeviceDb) { this.upnpdevicedb = upnpDeviceDb; } - public String getVeraAddress() { + public IpList getVeraAddress() { return veraaddress; } - public void setVeraAddress(String veraAddress) { + public void setVeraAddress(IpList veraAddress) { this.veraaddress = veraAddress; } public IpList getHarmonyAddress() { @@ -110,7 +110,8 @@ public void setNestConfigured(boolean isNestConfigured) { this.nestconfigured = isNestConfigured; } public Boolean isValidVera() { - if(this.veraaddress.contains(Configuration.DEFAULT_ADDRESS)) + List devicesList = this.veraaddress.getDevices(); + if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS)) return false; return true; } diff --git a/src/main/java/com/bwssystems/HABridge/HABridge.java b/src/main/java/com/bwssystems/HABridge/HABridge.java index 23292be8..bdf1eda6 100644 --- a/src/main/java/com/bwssystems/HABridge/HABridge.java +++ b/src/main/java/com/bwssystems/HABridge/HABridge.java @@ -89,7 +89,19 @@ public static void main(String[] args) { bridgeSettings.setUpnpDeviceDb(System.getProperty("upnp.device.db", Configuration.DEVICE_DB_DIRECTORY)); bridgeSettings.setUpnpResponsePort(System.getProperty("upnp.response.port", Configuration.UPNP_RESPONSE_PORT)); - bridgeSettings.setVeraAddress(System.getProperty("vera.address", Configuration.DEFAULT_ADDRESS)); + IpList theVeraList; + + try { + theVeraList = new Gson().fromJson(System.getProperty("vera.address", Configuration.DEFAULT_HARMONY_ADDRESS_LIST), IpList.class); + } catch (Exception e) { + try { + theVeraList = new Gson().fromJson("{devices:[{name:default,ip:" + System.getProperty("vera.address", Configuration.DEFAULT_ADDRESS) + "}]}", IpList.class); + } catch (Exception et) { + log.error("Cannot parse vera.address, Exiting with message: " + e.getMessage(), e); + return; + } + } + bridgeSettings.setVeraAddress(theVeraList); IpList theHarmonyList; try { diff --git a/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java b/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java index 43bfb1f5..1fe6c8ba 100644 --- a/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java +++ b/src/main/java/com/bwssystems/HABridge/devicemanagmeent/DeviceResource.java @@ -24,6 +24,7 @@ import com.bwssystems.NestBridge.NestHome; import com.bwssystems.harmony.HarmonyHome; import com.bwssystems.luupRequests.Sdata; +import com.bwssystems.vera.VeraHome; import com.bwssystems.vera.VeraInfo; import com.google.gson.Gson; @@ -35,7 +36,7 @@ public class DeviceResource { private static final Logger log = LoggerFactory.getLogger(DeviceResource.class); private DeviceRepository deviceRepository; - private VeraInfo veraInfo; + private VeraHome veraHome; private Version version; private HarmonyHome myHarmonyHome; private NestHome nestHome; @@ -43,7 +44,12 @@ public class DeviceResource { public DeviceResource(BridgeSettings theSettings, Version theVersion, HarmonyHome theHarmonyHome, NestHome aNestHome) { this.deviceRepository = new DeviceRepository(theSettings.getUpnpDeviceDb()); - this.veraInfo = new VeraInfo(theSettings.getVeraAddress(), theSettings.isValidVera()); + + if(theSettings.isValidVera()) + this.veraHome = new VeraHome(theSettings); + else + this.veraHome = null; + if(theSettings.isValidHarmony()) this.myHarmonyHome = theHarmonyHome; else @@ -53,6 +59,7 @@ public DeviceResource(BridgeSettings theSettings, Version theVersion, HarmonyHom this.nestHome = aNestHome; else this.nestHome = null; + this.version = theVersion; setupEndpoints(); } @@ -175,25 +182,23 @@ private void setupEndpoints() { get (API_CONTEXT + "/vera/devices", "application/json", (request, response) -> { log.debug("Get vera devices"); - Sdata sData = veraInfo.getSdata(); - if(sData == null){ + if(veraHome == null){ response.status(HttpStatus.SC_NOT_FOUND); return null; } response.status(HttpStatus.SC_OK); - return sData.getDevices(); + return veraHome.getDevices(); }, new JsonTransformer()); get (API_CONTEXT + "/vera/scenes", "application/json", (request, response) -> { log.debug("Get vera scenes"); - Sdata sData = veraInfo.getSdata(); - if(sData == null){ + if(veraHome == null){ response.status(HttpStatus.SC_NOT_FOUND); return null; } response.status(HttpStatus.SC_OK); - return sData.getScenes(); + return veraHome.getScenes(); }, new JsonTransformer()); get (API_CONTEXT + "/harmony/activities", "application/json", (request, response) -> { diff --git a/src/main/java/com/bwssystems/luupRequests/Device.java b/src/main/java/com/bwssystems/luupRequests/Device.java index e5babe27..717abf71 100644 --- a/src/main/java/com/bwssystems/luupRequests/Device.java +++ b/src/main/java/com/bwssystems/luupRequests/Device.java @@ -13,6 +13,8 @@ public class Device { private String level; private String state; private String comment; + private String veraname; + private String veraaddress; public String getName() { return name; } @@ -79,5 +81,17 @@ public String getComment() { public void setComment(String comment) { this.comment = comment; } + public String getVeraname() { + return veraname; + } + public void setVeraname(String veraname) { + this.veraname = veraname; + } + public String getVeraaddress() { + return veraaddress; + } + public void setVeraaddress(String veraaddress) { + this.veraaddress = veraaddress; + } } diff --git a/src/main/java/com/bwssystems/luupRequests/Scene.java b/src/main/java/com/bwssystems/luupRequests/Scene.java index 6f5fa84d..00f5563f 100644 --- a/src/main/java/com/bwssystems/luupRequests/Scene.java +++ b/src/main/java/com/bwssystems/luupRequests/Scene.java @@ -5,6 +5,8 @@ public class Scene { private String name; private String id; private String room; + private String veraname; + private String veraaddress; public String getActive() { return active; } @@ -29,5 +31,17 @@ public String getRoom() { public void setRoom(String room) { this.room = room; } + public String getVeraname() { + return veraname; + } + public void setVeraname(String veraname) { + this.veraname = veraname; + } + public String getVeraaddress() { + return veraaddress; + } + public void setVeraaddress(String veraaddress) { + this.veraaddress = veraaddress; + } } diff --git a/src/main/java/com/bwssystems/vera/VeraHome.java b/src/main/java/com/bwssystems/vera/VeraHome.java new file mode 100644 index 00000000..c5184cf7 --- /dev/null +++ b/src/main/java/com/bwssystems/vera/VeraHome.java @@ -0,0 +1,58 @@ +package com.bwssystems.vera; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.bwssystems.HABridge.BridgeSettings; +import com.bwssystems.HABridge.NamedIP; +import com.bwssystems.luupRequests.Device; +import com.bwssystems.luupRequests.Scene; + +public class VeraHome { + private static final Logger log = LoggerFactory.getLogger(VeraHome.class); + private Map veras; + + public VeraHome(BridgeSettings bridgeSettings) { + veras = new HashMap(); + if(!bridgeSettings.isValidVera()) + return; + Iterator theList = bridgeSettings.getVeraAddress().getDevices().iterator(); + while(theList.hasNext()) { + NamedIP aVera = theList.next(); + veras.put(aVera.getName(), new VeraInfo(aVera, bridgeSettings.isValidVera())); + } + } + + public List getDevices() { + log.debug("consolidating devices for veras"); + Iterator keys = veras.keySet().iterator(); + ArrayList deviceList = new ArrayList(); + while(keys.hasNext()) { + String key = keys.next(); + Iterator devices = veras.get(key).getSdata().getDevices().iterator(); + while(devices.hasNext()) { + deviceList.add(devices.next()); + } + } + return deviceList; + } + public List getScenes() { + log.debug("consolidating scenes for veras"); + Iterator keys = veras.keySet().iterator(); + ArrayList sceneList = new ArrayList(); + while(keys.hasNext()) { + String key = keys.next(); + Iterator scenes = veras.get(key).getSdata().getScenes().iterator(); + while(scenes.hasNext()) { + sceneList.add(scenes.next()); + } + } + return sceneList; + } +} diff --git a/src/main/java/com/bwssystems/vera/VeraInfo.java b/src/main/java/com/bwssystems/vera/VeraInfo.java index e1989d03..a371e124 100644 --- a/src/main/java/com/bwssystems/vera/VeraInfo.java +++ b/src/main/java/com/bwssystems/vera/VeraInfo.java @@ -13,6 +13,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.bwssystems.HABridge.NamedIP; import com.bwssystems.luupRequests.Categorie; import com.bwssystems.luupRequests.Device; import com.bwssystems.luupRequests.Room; @@ -25,13 +26,13 @@ public class VeraInfo { private static final Logger log = LoggerFactory.getLogger(VeraInfo.class); private HttpClient httpClient; private static final String SDATA_REQUEST = ":3480/data_request?id=sdata&output_format=json"; - private String veraAddressString; + private NamedIP veraAddress; private Boolean validVera; - public VeraInfo(String addressString, Boolean isValidVera) { + public VeraInfo(NamedIP addressName, Boolean isValidVera) { super(); httpClient = HttpClients.createDefault(); - veraAddressString = addressString; + veraAddress = addressName; validVera = isValidVera; } @@ -39,7 +40,7 @@ public Sdata getSdata() { if(!validVera) return new Sdata(); - String theUrl = "http://" + veraAddressString + SDATA_REQUEST; + String theUrl = "http://" + veraAddress.getIp() + SDATA_REQUEST; String theData; theData = doHttpGETRequest(theUrl); @@ -71,6 +72,8 @@ private void denormalizeSdata(Sdata theSdata) { theDevice.setCategory(categoryMap.get(theDevice.getCategory()).getName()); else theDevice.setCategory(""); + theDevice.setVeraaddress(veraAddress.getIp()); + theDevice.setVeraname(veraAddress.getName()); } ListIterator theSecneIter = theSdata.getScenes().listIterator(); @@ -81,6 +84,8 @@ private void denormalizeSdata(Sdata theSdata) { theScene.setRoom(roomMap.get(theScene.getRoom()).getName()); else theScene.setRoom("no room"); + theScene.setVeraaddress(veraAddress.getIp()); + theScene.setVeraname(veraAddress.getName()); } } diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js index 0c063d07..72307ee6 100644 --- a/src/main/resources/public/scripts/app.js +++ b/src/main/resources/public/scripts/app.js @@ -36,63 +36,9 @@ app.run( function (bridgeService) { bridgeService.getHABridgeVersion(); }); -app.factory('BridgeSettings', function() { - var BridgeSettings = {}; - - BridgeSettings.upnpconfigaddress = ""; - BridgeSettings.serverport = ""; - BridgeSettings.upnpdevicedb = ""; - BridgeSettings.upnpresponseport = ""; - BridgeSettings.veraaddress = ""; - BridgeSettings.harmonyaddress = ""; - BridgeSettings.upnpstrict = ""; - BridgeSettings.traceupnp = ""; - BridgeSettings.devmode = ""; - BridgeSettings.nestconfigured = ""; - - BridgeSettings.setupnpconfigaddress = function(aconfigaddress){ - BridgeSettings.upnpconfigaddress = aconfigaddress; - }; - - BridgeSettings.setserverport = function(aserverport){ - BridgeSettings.serverport = aserverport; - }; - - BridgeSettings.setupnpdevicedb = function(aupnpdevicedb){ - BridgeSettings.upnpdevicedb = aupnpdevicedb; - }; - - BridgeSettings.setupnpresponseport = function(aupnpresponseport){ - BridgeSettings.upnpresponseport = aupnpresponseport; - }; - - BridgeSettings.setveraaddress = function(averaaddress){ - BridgeSettings.veraaddress = averaaddress; - }; - BridgeSettings.setharmonyaddress = function(aharmonyaddress){ - BridgeSettings.harmonyaddress = aharmonyaddress; - }; - BridgeSettings.setupnpstrict = function(aupnpstrict){ - BridgeSettings.upnpstrict = aupnpstrict; - }; - BridgeSettings.settraceupnp = function(atraceupnp){ - BridgeSettings.traceupnp = atraceupnp; - }; - BridgeSettings.setdevmode = function(adevmode){ - BridgeSettings.devmode = adevmode; - }; - - BridgeSettings.setnestconfigured = function(anestconfigured){ - BridgeSettings.nestconfigured = anestconfigured; - }; - - return BridgeSettings; -}); - -app.service('bridgeService', function ($http, $window, BridgeSettings) { +app.service('bridgeService', function ($http, $window) { var self = this; - self.BridgeSettings = BridgeSettings; - this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/settings", huebase: window.location.origin + "/api", backups: [], devices: [], device: [], error: "", showVera: false, showHarmony: false, showNest: false, habridgeversion: ""}; + this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/settings", huebase: window.location.origin + "/api", backups: [], devices: [], device: [], settings: [], error: "", showVera: false, showHarmony: false, showNest: false, habridgeversion: ""}; this.viewDevices = function () { this.state.error = ""; @@ -133,7 +79,7 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) { } this.updateShowVera = function () { - if(this.aContainsB(self.BridgeSettings.veraaddress, "1.1.1.1") || self.BridgeSettings.veraaddress == "" || self.BridgeSettings.veraaddress == null) + if(this.aContainsB(self.state.settings.veraaddress.devices[0].ip, "1.1.1.1") || self.state.settings.veraaddress == "" || self.state.settings.veraaddress == null) this.state.showVera = false; else this.state.showVera = true; @@ -141,7 +87,7 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) { } this.updateShowNest = function () { - if(self.BridgeSettings.nestconfigured == true) + if(self.state.settings.nestconfigured == true) this.state.showNest = true; else this.state.showNest = false; @@ -149,8 +95,8 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) { } this.updateShowHarmony = function () { - if(self.BridgeSettings.harmonyaddress.devices) { - if(this.aContainsB(self.BridgeSettings.harmonyaddress.devices[0].ip, "1.1.1.1") || self.BridgeSettings.harmonyaddress == "" || self.BridgeSettings.harmonyaddress == null) + if(self.state.settings.harmonyaddress.devices) { + if(this.aContainsB(self.state.settings.harmonyaddress.devices[0].ip, "1.1.1.1") || self.state.settings.harmonyaddress == "" || self.state.settings.harmonyaddress == null) this.state.showHarmony = false; else this.state.showHarmony = true; @@ -165,16 +111,7 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) { this.state.error = ""; return $http.get(this.state.upnpbase).then( function (response) { - self.BridgeSettings.setupnpconfigaddress(response.data.upnpconfigaddress); - self.BridgeSettings.setserverport(response.data.serverport); - self.BridgeSettings.setupnpdevicedb(response.data.upnpdevicedb); - self.BridgeSettings.setupnpresponseport(response.data.upnpresponseport); - self.BridgeSettings.setveraaddress(response.data.veraaddress); - self.BridgeSettings.setharmonyaddress(response.data.harmonyaddress); - self.BridgeSettings.settraceupnp(response.data.traceupnp); - self.BridgeSettings.setupnpstrict(response.data.upnpstrict); - self.BridgeSettings.setdevmode(response.data.devmode); - self.BridgeSettings.setnestconfigured(response.data.nestconfigured); + self.state.settings = response.data; self.updateShowVera(); self.updateShowHarmony(); self.updateShowNest(); @@ -316,6 +253,8 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) { this.state.error = ""; if(device.httpVerb != null && device.httpVerb != "") device.deviceType = "custom"; + if(device.targetDevice == null || device.targetDevice == "") + device.targetDevice = "Encapsulated"; if (device.id) { var putUrl = this.state.base + "/" + device.id; return $http.put(putUrl, { @@ -345,8 +284,6 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) { } else { if(device.deviceType == null || device.deviceType == "") device.deviceType = "custom"; - if(device.httpVerb != null && device.httpVerb != "") - device.deviceType = "custom"; return $http.post(this.state.base, { name: device.name, mapId: device.mapId, @@ -477,9 +414,8 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) { }; }); -app.controller('ViewingController', function ($scope, $location, $http, $window, bridgeService, BridgeSettings) { +app.controller('ViewingController', function ($scope, $location, $http, $window, bridgeService) { - $scope.BridgeSettings = bridgeService.BridgeSettings; bridgeService.viewDevices(); bridgeService.viewBackups(); $scope.bridge = bridgeService.state; @@ -536,49 +472,48 @@ app.controller('ViewingController', function ($scope, $location, $http, $window, }; }); -app.controller('AddingController', function ($scope, $location, $http, bridgeService, BridgeSettings) { - $scope.device = {id: "", name: "", deviceType: "custom", onUrl: "", offUrl: ""}; - $scope.clearDevice = function () { - $scope.device.id = ""; - $scope.device.mapType = null; - $scope.device.mapId = null; - $scope.device.name = ""; - $scope.device.onUrl = ""; - $scope.device.deviceType = "custom"; - $scope.device.targetDevice = null; - $scope.device.offUrl = ""; - $scope.device.httpVerb = null; - $scope.device.contentType = null; - $scope.device.contentBody = null; - $scope.device.contentBodyOff = null; - }; - - - $scope.clearDevice(); - $scope.vera = {base: "", port: "3480", id: ""}; - $scope.vera.base = "http://" + BridgeSettings.veraaddress; +app.controller('AddingController', function ($scope, $location, $http, bridgeService) { + $scope.bridge = bridgeService.state; + $scope.device = $scope.bridge.device; + $scope.device_dim_control = ""; + $scope.bulk = { devices: [] }; + $scope.vera = {base: "http://" + $scope.bridge.settings.veraaddress, port: "3480", id: ""}; bridgeService.viewVeraDevices(); bridgeService.viewVeraScenes(); bridgeService.viewHarmonyActivities(); bridgeService.viewHarmonyDevices(); bridgeService.viewNestItems(); - $scope.bridge = bridgeService.state; $scope.imgButtonsUrl = "glyphicon glyphicon-plus"; $scope.buttonsVisible = false; + $scope.predicate = ''; $scope.reverse = true; - $scope.device_dim_control = ""; - $scope.bulk = { devices: [] }; $scope.order = function(predicate) { $scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : false; $scope.predicate = predicate; }; - $scope.buildUrlsUsingDevice = function (dim_control) { + $scope.clearDevice = function () { + $scope.device.id = ""; + $scope.device.mapType = null; + $scope.device.mapId = null; + $scope.device.name = ""; + $scope.device.onUrl = ""; + $scope.device.deviceType = "custom"; + $scope.device.targetDevice = null; + $scope.device.offUrl = ""; + $scope.device.httpVerb = null; + $scope.device.contentType = null; + $scope.device.contentBody = null; + $scope.device.contentBodyOff = null; + }; + + $scope.buildUrlsUsingDevice = function (dim_control) { if ($scope.vera.base.indexOf("http") < 0) { $scope.vera.base = "http://" + $scope.vera.base; } $scope.device.deviceType = "switch"; + $scope.device.targetDevice = $scope.bridge.settings.veraaddress; $scope.device.mapType = "veraDevice"; $scope.device.mapId = $scope.vera.id; if(dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) @@ -601,6 +536,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer $scope.vera.base = "http://" + $scope.vera.base; } $scope.device.deviceType = "scene"; + $scope.device.targetDevice = $scope.bridge.settings.veraaddress; $scope.device.mapType = "veraScene"; $scope.device.mapId = $scope.vera.id; $scope.device.onUrl = $scope.vera.base + ":" + $scope.vera.port @@ -617,6 +553,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer } $scope.device.deviceType = "switch"; $scope.device.name = veradevice.name; + $scope.device.targetDevice = veradevice.veraname; $scope.device.mapType = "veraDevice"; $scope.device.mapId = veradevice.id; if(dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) @@ -640,6 +577,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer } $scope.device.deviceType = "scene"; $scope.device.name = verascene.name; + $scope.device.targetDevice = verascene.veraname; $scope.device.mapType = "veraScene"; $scope.device.mapId = verascene.id; $scope.device.onUrl = $scope.vera.base + ":" + $scope.vera.port @@ -681,6 +619,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer $scope.buildNestHomeUrls = function (nestitem) { $scope.device.deviceType = "home"; $scope.device.name = nestitem.name; + $scope.device.targetDevice = nestitem.name; $scope.device.mapType = "nestHomeAway"; $scope.device.mapId = nestitem.id; $scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"away\":false,\"control\":\"status\"}"; @@ -690,6 +629,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer $scope.buildNestTempUrls = function (nestitem) { $scope.device.deviceType = "thermo"; $scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Temperature"; + $scope.device.targetDevice = nestitem.location; $scope.device.mapType = "nestThermoSet"; $scope.device.mapId = nestitem.id + "-SetTemp"; $scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"temp\",\"temp\":\"${intensity.percent}\"}"; @@ -699,6 +639,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer $scope.buildNestHeatUrls = function (nestitem) { $scope.device.deviceType = "thermo"; $scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Heat"; + $scope.device.targetDevice = nestitem.location; $scope.device.mapType = "nestThermoSet"; $scope.device.mapId = nestitem.id + "-SetHeat"; $scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"heat\"}"; @@ -708,6 +649,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer $scope.buildNestCoolUrls = function (nestitem) { $scope.device.deviceType = "thermo"; $scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Cool"; + $scope.device.targetDevice = nestitem.location; $scope.device.mapType = "nestThermoSet"; $scope.device.mapId = nestitem.id + "-SetCool"; $scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"cool\"}"; @@ -717,6 +659,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer $scope.buildNestRangeUrls = function (nestitem) { $scope.device.deviceType = "thermo"; $scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Range"; + $scope.device.targetDevice = nestitem.location; $scope.device.mapType = "nestThermoSet"; $scope.device.mapId = nestitem.id + "-SetRange"; $scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"range\"}"; @@ -726,6 +669,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer $scope.buildNestOffUrls = function (nestitem) { $scope.device.deviceType = "thermo"; $scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Thermostat"; + $scope.device.targetDevice = nestitem.location; $scope.device.mapType = "nestThermoSet"; $scope.device.mapId = nestitem.id + "-TurnOff"; $scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"range\"}"; @@ -735,6 +679,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer $scope.buildNestFanUrls = function (nestitem) { $scope.device.deviceType = "thermo"; $scope.device.name = nestitem.name.substr(0, nestitem.name.indexOf("(")) + " Fan"; + $scope.device.targetDevice = nestitem.location; $scope.device.mapType = "nestThermoSet"; $scope.device.mapId = nestitem.id + "-SetFan"; $scope.device.onUrl = "{\"name\":\"" + nestitem.id + "\",\"control\":\"fan-on\"}"; @@ -750,18 +695,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer return; bridgeService.addDevice($scope.device).then( function () { - $scope.device.id = ""; - $scope.device.mapType = null; - $scope.device.mapId = null; - $scope.device.name = ""; - $scope.device.onUrl = ""; - $scope.device.deviceType = "custom"; - $scope.device.targetDevice = null; - $scope.device.offUrl = ""; - $scope.device.httpVerb = null; - $scope.device.contentType = null; - $scope.device.contentBody = null; - $scope.device.contentBodyOff = null; + $scope.clearDevice(); }, function (error) { } @@ -843,7 +777,7 @@ app.filter('availableVeraDeviceId', function(bridgeService) { if(input == null) return out; for (var i = 0; i < input.length; i++) { - if(!bridgeService.findDeviceByMapId(input[i].id, null, "veraDevice")){ + if(!bridgeService.findDeviceByMapId(input[i].id, input[i].veraname, "veraDevice")){ out.push(input[i]); } } @@ -857,7 +791,7 @@ return function(input) { if(input == null) return out; for (var i = 0; i < input.length; i++) { - if(bridgeService.findDeviceByMapId(input[i].id, null, "veraDevice")){ + if(bridgeService.findDeviceByMapId(input[i].id, input[i].veraname, "veraDevice")){ out.push(input[i]); } } @@ -871,7 +805,7 @@ app.filter('availableVeraSceneId', function(bridgeService) { if(input == null) return out; for (var i = 0; i < input.length; i++) { - if(!bridgeService.findDeviceByMapId(input[i].id, null, "veraScene")){ + if(!bridgeService.findDeviceByMapId(input[i].id, input[i].veraname, "veraScene")){ out.push(input[i]); } } @@ -885,7 +819,7 @@ return function(input) { if(input == null) return out; for (var i = 0; i < input.length; i++) { - if(bridgeService.findDeviceByMapId(input[i].id, null, "veraScene")){ + if(bridgeService.findDeviceByMapId(input[i].id,input[i].veraname, "veraScene")){ out.push(input[i]); } } diff --git a/src/main/resources/public/views/configuration.html b/src/main/resources/public/views/configuration.html index b9066d1c..3920bee3 100644 --- a/src/main/resources/public/views/configuration.html +++ b/src/main/resources/public/views/configuration.html @@ -67,7 +67,7 @@

Current devices ({{bridge.devices.length}})

-

Bridge settings

+

Bridge Settings

diff --git a/src/main/resources/public/views/harmonyactivity.html b/src/main/resources/public/views/harmonyactivity.html index 806d4e35..9837dd2f 100644 --- a/src/main/resources/public/views/harmonyactivity.html +++ b/src/main/resources/public/views/harmonyactivity.html @@ -21,6 +21,7 @@

Harmony Activity List

+ + @@ -57,6 +59,7 @@

Already Configured Activities

+ diff --git a/src/main/resources/public/views/harmonydevice.html b/src/main/resources/public/views/harmonydevice.html index e26f3eaa..35417014 100644 --- a/src/main/resources/public/views/harmonydevice.html +++ b/src/main/resources/public/views/harmonydevice.html @@ -22,6 +22,7 @@

Harmony Device List

Row Name @@ -37,6 +38,7 @@

Harmony Activity List

{{$index+1}} {{harmonyactivity.activity.label}} {{harmonyactivity.activity.id}} {{harmonyactivity.hub}}
Row Name @@ -73,6 +76,7 @@

Already Configured Activities +

{{$index+1}} {{harmonyactivity.activity.label}} {{harmonyactivity.activity.id}} {{harmonyactivity.hub}}
+ + @@ -74,6 +76,7 @@

Already Configured Harmony Buttons

+ diff --git a/src/main/resources/public/views/nestactions.html b/src/main/resources/public/views/nestactions.html index 0ba52ee3..9681650a 100644 --- a/src/main/resources/public/views/nestactions.html +++ b/src/main/resources/public/views/nestactions.html @@ -21,6 +21,7 @@

Nest Items List

Row Name @@ -40,6 +41,7 @@

Harmony Device List

{{$index+1}} {{harmonydevice.device.label}} {{harmonydevice.device.id}} {{harmonydevice.hub}}
Row Name @@ -94,6 +97,7 @@

Already Configured Harmony Buttons +

{{$index+1}} {{device.name}} {{device.id}} {{device.targetDevice}}
+ + @@ -78,6 +80,7 @@

Already Configured Nest Items

+ diff --git a/src/main/resources/public/views/veradevice.html b/src/main/resources/public/views/veradevice.html index ad0fad5e..e18ebf3f 100644 --- a/src/main/resources/public/views/veradevice.html +++ b/src/main/resources/public/views/veradevice.html @@ -48,6 +48,10 @@

Vera Device List ({{bridge.veradevices.length}})

+ @@ -58,6 +62,7 @@

Vera Device List ({{bridge.veradevices.length}})

+ + + + +
Row Name @@ -37,6 +38,7 @@

Nest Items List

{{$index+1}} {{nestitem.name}} {{nestitem.type}} {{nestitem.location}}
Row Name @@ -94,6 +97,7 @@

Already Configured Nest Items +

{{$index+1}} {{device.name}} {{device.id}} {{device.mapId}} Room + + Vera + Actions
{{veradevice.id}} {{veradevice.category}} {{veradevice.room}}{{veradevice.veraname}}
Row Name @@ -94,15 +100,21 @@

Already Configured Vera Devices Room +

+ Vera + Actions
{{$index+1}} {{veradevice.name}} {{veradevice.id}} {{veradevice.category}} {{veradevice.room}}{{veradevice.veraname}} diff --git a/src/main/resources/public/views/verascene.html b/src/main/resources/public/views/verascene.html index a6b0995f..09114e3c 100644 --- a/src/main/resources/public/views/verascene.html +++ b/src/main/resources/public/views/verascene.html @@ -21,6 +21,7 @@

Vera Scene List

+ + + + + + + +
Row Name @@ -32,14 +33,20 @@

Vera Scene List

Room + + Vera + Actions
{{$index+1}} {{verascene.name}} {{verascene.id}} {{verascene.room}}{{verascene.veraname}}
Row Name @@ -68,14 +76,20 @@

Already Configured Vera Scenes Room +

+ Vera + Actions
{{$index+1}} {{verascene.name}} {{verascene.id}} {{verascene.room}}{{verascene.veraname}}