diff --git a/pom.xml b/pom.xml index 76577d9..67f4d30 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.bwssystems.HABridge ha-bridge - 1.1.0g + 1.1.0i jar HA Bridge diff --git a/src/main/java/com/bwssystems/harmony/HarmonyDevice.java b/src/main/java/com/bwssystems/harmony/HarmonyDevice.java index a1a5fcc..7deaac6 100644 --- a/src/main/java/com/bwssystems/harmony/HarmonyDevice.java +++ b/src/main/java/com/bwssystems/harmony/HarmonyDevice.java @@ -1,5 +1,20 @@ package com.bwssystems.harmony; -public class HarmonyDevice { +import net.whistlingfish.harmony.config.Device; +public class HarmonyDevice { + private Device device; + private String hub; + public Device getDevice() { + return device; + } + public void setDevice(Device device) { + this.device = device; + } + public String getHub() { + return hub; + } + public void setHub(String hub) { + this.hub = hub; + } } diff --git a/src/main/java/com/bwssystems/harmony/HarmonyHome.java b/src/main/java/com/bwssystems/harmony/HarmonyHome.java index 58d98e0..8ee8afc 100644 --- a/src/main/java/com/bwssystems/harmony/HarmonyHome.java +++ b/src/main/java/com/bwssystems/harmony/HarmonyHome.java @@ -1,9 +1,9 @@ package com.bwssystems.harmony; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.ListIterator; import java.util.Map; import java.util.Set; @@ -14,6 +14,7 @@ import com.bwssystems.HABridge.BridgeSettings; import com.bwssystems.HABridge.NamedIP; import net.whistlingfish.harmony.config.Activity; +import net.whistlingfish.harmony.config.Device; public class HarmonyHome { private static final Logger log = LoggerFactory.getLogger(HarmonyHome.class); @@ -35,36 +36,67 @@ public class HarmonyHome { } public HarmonyHandler getHarmonyHandler(String aName) { + HarmonyHandler aHandler = null; if(aName == null || aName.equals("")) { - HarmonyHandler aHandler = hubs.get("default").getMyHarmony(); - if(aHandler == null) { - Set keys = hubs.keySet(); - if(!keys.isEmpty()) { - aHandler = hubs.get(keys.toArray()[0]).getMyHarmony(); - } - else - aHandler = null; - } - return aHandler; + aName = "default"; } - return hubs.get(aName).getMyHarmony(); + + if(hubs.get(aName) == null) { + Set keys = hubs.keySet(); + if(!keys.isEmpty()) { + aHandler = hubs.get(keys.toArray()[0]).getMyHarmony(); + } + else + aHandler = null; + } + else + aHandler = hubs.get(aName).getMyHarmony(); + return aHandler; } public List getActivities() { Iterator keys = hubs.keySet().iterator(); + ArrayList activityList = new ArrayList(); while(keys.hasNext()) { - List theActivities = hubs.get(keys.next()).getMyHarmony().getActivities(); - ListIterator activities = theActivities.listIterator(); + String key = keys.next(); + Iterator activities = hubs.get(key).getMyHarmony().getActivities().iterator(); while(activities.hasNext()) { - + HarmonyActivity anActivity = new HarmonyActivity(); + anActivity.setActivity(activities.next()); + anActivity.setHub(key); + activityList.add(anActivity); } } - return null; + return activityList; } - public List getCurrentActivities() { - return null; + public List getCurrentActivities() { + Iterator keys = hubs.keySet().iterator(); + ArrayList activityList = new ArrayList(); + while(keys.hasNext()) { + String key = keys.next(); + Iterator activities = hubs.get(key).getMyHarmony().getActivities().iterator(); + while(activities.hasNext()) { + HarmonyActivity anActivity = new HarmonyActivity(); + anActivity.setActivity(activities.next()); + anActivity.setHub(key); + activityList.add(anActivity); + } + } + return activityList; } public List getDevices() { - return null; + Iterator keys = hubs.keySet().iterator(); + ArrayList deviceList = new ArrayList(); + while(keys.hasNext()) { + String key = keys.next(); + Iterator devices = hubs.get(key).getMyHarmony().getDevices().iterator(); + while(devices.hasNext()) { + HarmonyDevice aDevice = new HarmonyDevice(); + aDevice.setDevice(devices.next()); + aDevice.setHub(key); + deviceList.add(aDevice); + } + } + return deviceList; } } diff --git a/src/main/resources/public/index.html b/src/main/resources/public/index.html index 656c3fe..fe08eda 100644 --- a/src/main/resources/public/index.html +++ b/src/main/resources/public/index.html @@ -29,6 +29,7 @@ Home My Echo + Help Type + + Target + Actions @@ -44,6 +47,7 @@ {{device.id}} {{device.name}} {{device.deviceType}} + {{device.targetDevice}} Test ON @@ -66,7 +70,7 @@ - Bridge + Bridge server diff --git a/src/main/resources/public/views/editdevice.html b/src/main/resources/public/views/editdevice.html index 0bd0b17..2cf0e47 100644 --- a/src/main/resources/public/views/editdevice.html +++ b/src/main/resources/public/views/editdevice.html @@ -26,6 +26,15 @@ Update Device + + Target + + + + + + Map Type diff --git a/src/main/resources/public/views/harmonyactivity.html b/src/main/resources/public/views/harmonyactivity.html index f0f80fb..b228873 100644 --- a/src/main/resources/public/views/harmonyactivity.html +++ b/src/main/resources/public/views/harmonyactivity.html @@ -26,13 +26,18 @@ Id + + + Hub + Actions - {{harmonyactivity.label}} - {{harmonyactivity.id}} + {{harmonyactivity.activity.label}} + {{harmonyactivity.activity.id}} + {{harmonyactivity.hub}} Generate @@ -57,15 +62,20 @@ Id + + + Hub + Actions - {{harmonyactivity.label}} - {{harmonyactivity.id}} + {{harmonyactivity.activity.label}} + {{harmonyactivity.activity.id}} + {{harmonyactivity.hub}} Delete + ng-click="deleteDeviceByMapId(harmonyactivity.activity.id, 'harmonyActivity')">Delete diff --git a/src/main/resources/public/views/harmonydevice.html b/src/main/resources/public/views/harmonydevice.html index b10c325..3bb58f3 100644 --- a/src/main/resources/public/views/harmonydevice.html +++ b/src/main/resources/public/views/harmonydevice.html @@ -26,6 +26,10 @@ Id + + + Hub + On Button Off Button @@ -33,18 +37,19 @@ - {{harmonydevice.label}} - {{harmonydevice.id}} + {{harmonydevice.device.label}} + {{harmonydevice.device.id}} + {{harmonydevice.hub}} - + {{funcon.name}} - + {{funcoff.name}} @@ -73,6 +78,10 @@ Device Id + + + Hub + Harmony Device-Button On-Button Off @@ -84,6 +93,7 @@ {{device.name}} {{device.id}} + {{device.targetDevice}} {{device.mapId}}