diff --git a/pom.xml b/pom.xml index 20d58f8..aa68640 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.bwssystems.HABridge ha-bridge - 5.3.0RC2 + 5.3.0RC3 jar HA Bridge diff --git a/src/main/java/com/bwssystems/HABridge/plugins/hass/HomeAssistant.java b/src/main/java/com/bwssystems/HABridge/plugins/hass/HomeAssistant.java index b5d40d6..5c1cd11 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/hass/HomeAssistant.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/hass/HomeAssistant.java @@ -20,12 +20,14 @@ public class HomeAssistant { private NamedIP hassAddress; private HTTPHandler anHttpHandler; private HassAuth theAuthType; + private NameValue[] headers; public HomeAssistant(NamedIP addressName) { super(); anHttpHandler = HTTPHome.getHandler(); hassAddress = addressName; theAuthType = null; + headers = null; isLegacyAuth(); } @@ -48,14 +50,7 @@ public class HomeAssistant { else aUrl = aUrl + domain; String aBody = "{\"entity_id\":\"" + aCommand.getEntityId() + "\""; - NameValue[] headers = null; - if (hassAddress.getPassword() != null && !hassAddress.getPassword().isEmpty()) { - NameValue password = new NameValue(); - password.setName("x-ha-access"); - password.setValue(hassAddress.getPassword()); - headers = new NameValue[1]; - headers[0] = password; - } + headers = getAuthHeader(); if (aCommand.getState().equalsIgnoreCase("on")) { aUrl = aUrl + "/turn_on"; if (aCommand.getBri() != null) @@ -77,15 +72,7 @@ public class HomeAssistant { State[] theHassStates; String theUrl = null; String theData; - NameValue[] headers = null; - // do check for what type of auth: bearer token or legacy password - if (hassAddress.getPassword() != null && !hassAddress.getPassword().isEmpty()) { - NameValue password = new NameValue(); - password.setName("x-ha-access"); - password.setValue(hassAddress.getPassword()); - headers = new NameValue[1]; - headers[0] = password; - } + headers = getAuthHeader(); if (hassAddress.getSecure() != null && hassAddress.getSecure()) theUrl = "https"; else @@ -123,4 +110,23 @@ public class HomeAssistant { } return theAuthType.isLegacyauth(); } + + private NameValue[] getAuthHeader() { + if (headers == null) { + if (hassAddress.getPassword() != null && !hassAddress.getPassword().isEmpty()) { + headers = new NameValue[1]; + headers[0] = new NameValue(); + if (isLegacyAuth()) { + headers[0].setName("x-ha-access"); + headers[0].setValue(hassAddress.getPassword()); + } else { + headers[0].setName("Authorization"); + headers[0].setValue("Bearer " + hassAddress.getPassword()); + } + } + } else if(hassAddress.getPassword() == null || hassAddress.getPassword().isEmpty()) { + headers = null; + } + return headers; + } } diff --git a/src/main/resources/public/css/scrollable-table.css b/src/main/resources/public/css/scrollable-table.css index 28eaba1..09ec931 100644 --- a/src/main/resources/public/css/scrollable-table.css +++ b/src/main/resources/public/css/scrollable-table.css @@ -29,7 +29,9 @@ .scrollArea { height: 100%; +/* THis makes the table scroll - disabled as a feature for now max-height: 800px; +*/ overflow-x: auto; overflow-y: auto; border: 1px solid #d5d5d5; diff --git a/src/main/resources/public/views/system.html b/src/main/resources/public/views/system.html index bf31d2e..d3b341d 100644 --- a/src/main/resources/public/views/system.html +++ b/src/main/resources/public/views/system.html @@ -37,8 +37,8 @@ server
- Save - Bridge Reinitialize - Bridge Stop - Update Security Settings + Save + Bridge Reinitialize + Bridge Stop + Update Security + Settings