Check broadlink map before finding device to call for null. Initialize

broadlink Map on discover.
This commit is contained in:
bsamuels
2018-02-13 16:12:05 -06:00
parent 869ffaaf36
commit 271bd3913c
2 changed files with 8 additions and 2 deletions

View File

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

View File

@@ -108,7 +108,7 @@ public class BroadlinkHome implements Home {
+ "\",\"description\": \"Should not get here, no LifxDevices configured\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
} else {
} else if(broadlinkMap != null) {
BroadlinkEntry broadlinkCommand = null;
broadlinkCommand = new Gson().fromJson(anItem.getItem().getAsString(), BroadlinkEntry.class);
BLDevice theDevice = broadlinkMap.get(broadlinkCommand.getId());
@@ -255,6 +255,11 @@ public class BroadlinkHome implements Home {
}
}
} else {
log.warn("Should not get here, no BroadlinkDevices available");
theReturn = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
+ "\",\"description\": \"Should not get here, no Broadlinks available\", \"parameter\": \"/lights/"
+ lightId + "state\"}}]";
}
return theReturn;
}
@@ -311,6 +316,7 @@ public class BroadlinkHome implements Home {
public BLDevice[] broadlinkDiscover () {
BLDevice[] clients = null;
int aDiscoverPort = Configuration.BROADLINK_DISCOVER_PORT;
broadlinkMap = new HashMap<String, BLDevice>();
while(aDiscoverPort > 0) {
try {
log.info("Broadlink discover....");