Fixed handling when no harmony hub is given. dev.mode was updated as

well.

This closes #14.
This commit is contained in:
Admin
2015-12-03 14:36:23 -06:00
parent 2a52783bb1
commit 5a843f7569
7 changed files with 64 additions and 34 deletions

View File

@@ -5,7 +5,7 @@
<groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<packaging>jar</packaging>
<name>HA Bridge</name>

View File

@@ -41,7 +41,10 @@ public class DeviceResource {
public DeviceResource(BridgeSettings theSettings, Version theVersion, HarmonyHome theHarmonyHome) {
this.deviceRepository = new DeviceRepository(theSettings.getUpnpDeviceDb());
this.veraInfo = new VeraInfo(theSettings.getVeraAddress(), theSettings.isValidVera());
this.myHarmonyHome = theHarmonyHome;
if(theSettings.isValidHarmony())
this.myHarmonyHome = theHarmonyHome;
else
this.myHarmonyHome = null;
this.version = theVersion;
setupEndpoints();
}

View File

@@ -68,7 +68,10 @@ public class HueMulator {
mapper = new ObjectMapper(); //armzilla: work around Echo incorrect content type and breaking mapping. Map manually
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
repository = aDeviceRepository;
myHarmonyHome = theHarmonyHome;
if(theBridgeSettings.isValidHarmony())
this.myHarmonyHome = theHarmonyHome;
else
this.myHarmonyHome = null;
bridgeSettings = theBridgeSettings;
}

View File

@@ -40,9 +40,19 @@ public class UpnpSettingsResource {
+ "<depth>24</depth>\n" + "<url>hue_logo_3.png</url>\n" + "</icon>\n" + "</iconList>\n" + "</device>\n"
+ "</root>\n";
public UpnpSettingsResource(BridgeSettings theSettings) {
public UpnpSettingsResource(BridgeSettings theBridgeSettings) {
super();
this.theSettings = theSettings;
this.theSettings = new BridgeSettings();
this.theSettings.setDevMode(theBridgeSettings.isDevMode());
this.theSettings.setHarmonyAddress(theBridgeSettings.getHarmonyAddress());
this.theSettings.setServerPort(theBridgeSettings.getServerPort());
this.theSettings.setTraceupnp(theBridgeSettings.isTraceupnp());
this.theSettings.setUpnpConfigAddress(theBridgeSettings.getUpnpConfigAddress());
this.theSettings.setUpnpDeviceDb(theBridgeSettings.getUpnpDeviceDb());
this.theSettings.setUpnpResponseDevices(theBridgeSettings.getUpnpResponseDevices());
this.theSettings.setUpnpResponsePort(theBridgeSettings.getUpnpResponsePort());
this.theSettings.setUpnpStrict(theBridgeSettings.isUpnpStrict());
this.theSettings.setVeraAddress(theBridgeSettings.getVeraAddress());
}
public void setupServer() {

View File

@@ -11,6 +11,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.bwssystems.HABridge.BridgeSettings;
import com.bwssystems.HABridge.IpList;
import com.bwssystems.HABridge.NamedIP;
import net.whistlingfish.harmony.config.Activity;
@@ -23,6 +24,18 @@ public class HarmonyHome {
public HarmonyHome(BridgeSettings bridgeSettings) {
super();
hubs = new HashMap<String, HarmonyServer>();
if(!bridgeSettings.isValidHarmony() && !bridgeSettings.isDevMode())
return;
if(bridgeSettings.isDevMode()) {
NamedIP devModeIp = new NamedIP();
devModeIp.setIp("10.10.10.10");
devModeIp.setName("devMode");
List<NamedIP> theList = new ArrayList<NamedIP>();
theList.add(devModeIp);
IpList thedevList = new IpList();
thedevList.setDevices(theList);
bridgeSettings.setHarmonyAddress(thedevList);
}
Iterator<NamedIP> theList = bridgeSettings.getHarmonyAddress().getDevices().iterator();
while(theList.hasNext()) {
NamedIP aHub = theList.next();

View File

@@ -37,7 +37,7 @@ public class HarmonyServer {
}
public static HarmonyServer setup(BridgeSettings bridgeSettings, NamedIP theHarmonyAddress) throws Exception {
if(!bridgeSettings.isValidHarmony()) {
if(!bridgeSettings.isValidHarmony() && !bridgeSettings.isDevMode()) {
return new HarmonyServer(theHarmonyAddress);
}
Injector injector = null;

View File

@@ -124,6 +124,31 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) {
);
};
this.aContainsB = function (a, b) {
return a.indexOf(b) >= 0;
}
this.updateShowVera = function () {
if(this.aContainsB(self.BridgeSettings.veraaddress, "1.1.1.1") || self.BridgeSettings.veraaddress == "" || self.BridgeSettings.veraaddress == null)
this.state.showVera = false;
else
this.state.showVera = true;
return;
}
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)
this.state.showHarmony = false;
else
this.state.showHarmony = true;
}
else
this.state.showHarmony = false;
return;
}
this.loadBridgeSettings = function () {
this.state.error = "";
return $http.get(this.state.upnpbase).then(
@@ -137,14 +162,6 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) {
self.BridgeSettings.settraceupnp(response.data.traceupnp);
self.BridgeSettings.setupnpstrict(response.data.upnpstrict);
self.BridgeSettings.setdevmode(response.data.devmode);
if(self.BridgeSettings.veraaddress == "1.1.1.1" || self.BridgeSettings.veraaddress == "")
self.state.showVera = false;
else
self.state.showVera = true;
if(self.BridgeSettings.harmonyaddress == "1.1.1.1" || self.BridgeSettings.harmonyaddress == "")
self.state.showHarmony = false;
else
self.state.showHarmony = true;
},
function (error) {
if (error.data) {
@@ -157,22 +174,6 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) {
);
};
this.updateShowVera = function () {
if(self.BridgeSettings.veraaddress == "1.1.1.1" || self.BridgeSettings.veraaddress == "")
this.state.showVera = false;
else
this.state.showVera = true;
return;
}
this.updateShowHarmony = function () {
if(self.BridgeSettings.harmonyaddress == "1.1.1.1" || self.BridgeSettings.harmonyaddress == "")
this.state.showHarmony = false;
else
this.state.showHarmony = true;
return;
}
this.viewVeraDevices = function () {
this.state.error = "";
if(!this.state.showVera)
@@ -632,7 +633,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, "veraDevice")){
if(!bridgeService.findDeviceByMapId(input[i].id, null, "veraDevice")){
out.push(input[i]);
}
}
@@ -646,7 +647,7 @@ return function(input) {
if(input == null)
return out;
for (var i = 0; i < input.length; i++) {
if(bridgeService.findDeviceByMapId(input[i].id, "veraDevice")){
if(bridgeService.findDeviceByMapId(input[i].id, null, "veraDevice")){
out.push(input[i]);
}
}
@@ -660,7 +661,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, "veraScene")){
if(!bridgeService.findDeviceByMapId(input[i].id, null, "veraScene")){
out.push(input[i]);
}
}
@@ -674,7 +675,7 @@ return function(input) {
if(input == null)
return out;
for (var i = 0; i < input.length; i++) {
if(bridgeService.findDeviceByMapId(input[i].id, "veraScene")){
if(bridgeService.findDeviceByMapId(input[i].id, null, "veraScene")){
out.push(input[i]);
}
}