From fb9cc648398c660b2d96f28551077620296a50ec Mon Sep 17 00:00:00 2001 From: Admin Date: Fri, 26 May 2017 15:36:01 -0500 Subject: [PATCH] Fix HAL connect issues. --- .../com/bwssystems/HABridge/plugins/hal/HalHome.java | 10 ++++++++-- .../com/bwssystems/HABridge/plugins/hal/HalInfo.java | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/bwssystems/HABridge/plugins/hal/HalHome.java b/src/main/java/com/bwssystems/HABridge/plugins/hal/HalHome.java index 234803b..adb7b98 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/hal/HalHome.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/hal/HalHome.java @@ -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 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, diff --git a/src/main/java/com/bwssystems/HABridge/plugins/hal/HalInfo.java b/src/main/java/com/bwssystems/HABridge/plugins/hal/HalInfo.java index 89189ed..abd02a5 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/hal/HalInfo.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/hal/HalInfo.java @@ -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(); while (theHalDevices.hasNext()) { HalDevice theHalDevice = theHalDevices.next(); - if(halAddress.getSecure()) + if(halAddress.getSecure()!= null && halAddress.getSecure()) theUrl = "https://"; else theUrl = "http://";