mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 08:13:23 +00:00
Fix HAL connect issues.
This commit is contained in:
@@ -114,7 +114,7 @@ public class HalHome implements Home {
|
|||||||
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
||||||
String responseString = null;
|
String responseString = null;
|
||||||
String theUrl = anItem.getItem().getAsString();
|
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 intermediate = theUrl.substring(theUrl.indexOf("://") + 3);
|
||||||
String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
|
String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
|
||||||
// String theUrlBody = intermediate.substring(intermediate.indexOf('/') + 1);
|
// String theUrlBody = intermediate.substring(intermediate.indexOf('/') + 1);
|
||||||
@@ -129,7 +129,9 @@ public class HalHome implements Home {
|
|||||||
+ (anItem.getHttpVerb() == null ? "GET" : anItem.getHttpVerb()) + ": "
|
+ (anItem.getHttpVerb() == null ? "GET" : anItem.getHttpVerb()) + ": "
|
||||||
+ anItem.getItem().getAsString());
|
+ anItem.getItem().getAsString());
|
||||||
|
|
||||||
String anUrl = BrightnessDecode.calculateReplaceIntensityValue(theUrl,
|
String anUrl = intermediate;
|
||||||
|
|
||||||
|
anUrl = BrightnessDecode.calculateReplaceIntensityValue(anUrl,
|
||||||
intensity, targetBri, targetBriInc, false);
|
intensity, targetBri, targetBriInc, false);
|
||||||
anUrl = DeviceDataDecode.replaceDeviceData(anUrl, device);
|
anUrl = DeviceDataDecode.replaceDeviceData(anUrl, device);
|
||||||
anUrl = TimeDecode.replaceTimeValue(anUrl);
|
anUrl = TimeDecode.replaceTimeValue(anUrl);
|
||||||
@@ -137,6 +139,10 @@ public class HalHome implements Home {
|
|||||||
for (Map.Entry<String, HalInfo> entry : hals.entrySet())
|
for (Map.Entry<String, HalInfo> entry : hals.entrySet())
|
||||||
{
|
{
|
||||||
if(entry.getValue().getHalAddress().getIp().equals(hostAddr)) {
|
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) {
|
if (entry.getValue().deviceCommand(anUrl) == null) {
|
||||||
log.warn("Error on calling hal to change device state: " + anUrl);
|
log.warn("Error on calling hal to change device state: " + anUrl);
|
||||||
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
|
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class HalInfo {
|
|||||||
|
|
||||||
String theUrl = null;
|
String theUrl = null;
|
||||||
String theData;
|
String theData;
|
||||||
if(halAddress.getSecure())
|
if(halAddress.getSecure()!= null && halAddress.getSecure())
|
||||||
theUrl = "https://";
|
theUrl = "https://";
|
||||||
else
|
else
|
||||||
theUrl = "http://";
|
theUrl = "http://";
|
||||||
@@ -150,7 +150,7 @@ public class HalInfo {
|
|||||||
deviceList = new ArrayList<HalDevice>();
|
deviceList = new ArrayList<HalDevice>();
|
||||||
while (theHalDevices.hasNext()) {
|
while (theHalDevices.hasNext()) {
|
||||||
HalDevice theHalDevice = theHalDevices.next();
|
HalDevice theHalDevice = theHalDevices.next();
|
||||||
if(halAddress.getSecure())
|
if(halAddress.getSecure()!= null && halAddress.getSecure())
|
||||||
theUrl = "https://";
|
theUrl = "https://";
|
||||||
else
|
else
|
||||||
theUrl = "http://";
|
theUrl = "http://";
|
||||||
|
|||||||
Reference in New Issue
Block a user