Fix HAL connect issues.

This commit is contained in:
Admin
2017-05-26 15:36:01 -05:00
parent 409c93bfb2
commit fb9cc64839
2 changed files with 10 additions and 4 deletions

View File

@@ -114,7 +114,7 @@ public class HalHome implements Home {
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
String responseString = null;
String theUrl = anItem.getItem().getAsString();
if(theUrl != null && !theUrl.isEmpty () && theUrl.contains("http://")) {
if(theUrl != null && !theUrl.isEmpty () && theUrl.contains("http")) {
String intermediate = theUrl.substring(theUrl.indexOf("://") + 3);
String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
// String theUrlBody = intermediate.substring(intermediate.indexOf('/') + 1);
@@ -129,7 +129,9 @@ public class HalHome implements Home {
+ (anItem.getHttpVerb() == null ? "GET" : anItem.getHttpVerb()) + ": "
+ anItem.getItem().getAsString());
String anUrl = BrightnessDecode.calculateReplaceIntensityValue(theUrl,
String anUrl = intermediate;
anUrl = BrightnessDecode.calculateReplaceIntensityValue(anUrl,
intensity, targetBri, targetBriInc, false);
anUrl = DeviceDataDecode.replaceDeviceData(anUrl, device);
anUrl = TimeDecode.replaceTimeValue(anUrl);
@@ -137,6 +139,10 @@ public class HalHome implements Home {
for (Map.Entry<String, HalInfo> entry : hals.entrySet())
{
if(entry.getValue().getHalAddress().getIp().equals(hostAddr)) {
if(entry.getValue().getHalAddress().getSecure()!= null && entry.getValue().getHalAddress().getSecure())
anUrl = "https://" + anUrl;
else
anUrl = "http://" + anUrl;
if (entry.getValue().deviceCommand(anUrl) == null) {
log.warn("Error on calling hal to change device state: " + anUrl);
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,

View File

@@ -98,7 +98,7 @@ public class HalInfo {
String theUrl = null;
String theData;
if(halAddress.getSecure())
if(halAddress.getSecure()!= null && halAddress.getSecure())
theUrl = "https://";
else
theUrl = "http://";
@@ -150,7 +150,7 @@ public class HalInfo {
deviceList = new ArrayList<HalDevice>();
while (theHalDevices.hasNext()) {
HalDevice theHalDevice = theHalDevices.next();
if(halAddress.getSecure())
if(halAddress.getSecure()!= null && halAddress.getSecure())
theUrl = "https://";
else
theUrl = "http://";