From 46ad4489add5ffa86f41ec3e373ffc7eb73fffdc Mon Sep 17 00:00:00 2001 From: BWS Systems Date: Fri, 14 Jun 2019 10:32:15 -0500 Subject: [PATCH] Finish HomeAssistant auth changes and implement no scroll for pages --- pom.xml | 2 +- .../HABridge/plugins/hass/HomeAssistant.java | 40 +- .../resources/public/css/scrollable-table.css | 2 + src/main/resources/public/views/system.html | 1043 +++++++---------- 4 files changed, 481 insertions(+), 606 deletions(-) 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
- +
@@ -46,14 +46,14 @@

- - - - + + + +

@@ -64,67 +64,53 @@ - + - + - + - + - + - + - + - + - + - - - - - - - - + - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - +
Configuration Path and File
Device DB Path and File
Groups DB Path and File
UPNP IP Address
Use UPNP Address Interface Only {{bridge.settings.useupnpiface}} {{bridge.settings.useupnpiface}}
Use Rooms for Alexa {{bridge.settings.userooms}} {{bridge.settings.userooms}}
Web Server IP Address
Web Server Port
UPNP Response Port
Vera Names and IP Addresses + +
+ @@ -133,31 +119,28 @@ - - + + - - + + -
Name
+
Fibaro Names and IP Addresses + +
+ @@ -170,115 +153,96 @@ - - - - - - + + + + + + ng-click="removeFibarotoSettings(fibaro.name, fibaro.ip, fibaro.port)">Del + - - - - - - + + + + + + ng-click="addFibarotoSettings(newfibaroname, newfibaroip, newfibaroport, newfibarousername, newfibaropassword, filters)">Add + -
Name
Save Logs - User Desc - Lili Cmd - Trash Chars + Save Logs + User Desc + Lili Cmd + Trash Chars
Save Logs - User Desc - Lili Cmd - Trash Chars Save Logs + User Desc + Lili Cmd + Trash Chars
+
Harmony Names and IP Addresses + +
+ - - + + - - - + + + - - - + + + + ng-click="addHarmonytoSettings(newharmonyname, newharmonyip, newharmonywebhook)">Add + -
NameIPWebhookIPWebhook Manage
+
Hue Names and IP Addresses + +
+ @@ -287,31 +251,28 @@ - - + + + ng-click="removeHuetoSettings(hue.name, hue.ip)">Del - - + + + ng-click="addHuetoSettings(newhuename, newhueip)">Add -
Name
+
HAL Names and IP Addresses + +
+ @@ -322,43 +283,37 @@ - - - - + + + - - - - + + + + ng-click="addHaltoSettings(newhalname, newhalip, newhalsecure, newhaltoken)">Add + -
Name
+
MQTT Client IDs and IP Addresses + +
+ @@ -369,43 +324,37 @@ - - - - + + + + - - - - + + + + + ng-click="addMQTTtoSettings(newmqttname, newmqttip, newmqttusername, newmqttpassword)">Add + -
Client ID
+
HomeAssistant Names and IP Addresses + +
+ @@ -418,61 +367,47 @@ - - - - - + + + + - - - - - - - + + + + + + ng-click="addHasstoSettings(newhassname, newhassip, newhassport, newhasspassword, newhasssecure, newhassauth)">Add + -
Name
- Legacy Password - + Legacy Password
- Legacy Password - - Legacy Password +
+
HomeWizard Gateways + - +
+ @@ -483,43 +418,41 @@ - - - - + + + + + ng-click="removeHomeWizardtoSettings(homewizard.name, homewizard.ip)">Del + - - - - + + + + + ng-click="addHomeWizardtoSettings(newhomewizardname, newhomewizardip, newhomewizardusername, newhomewizardpassword)">Add + -
Name
+
+
Domoticz Names and IP Addresses + +
+ @@ -532,102 +465,89 @@ - - - - - - + + + + + + ng-click="removeDomoticztoSettings(domoticz.name, domoticz.ip)">Del + - - - - - - + + + + + + ng-click="addDomoticztoSettings(newdomoticzname, newdomoticzip, newdomoticzport, newdomoticzusername, newdomoticzpassword, newdomoticzsecure)">Add + -
Name
+
Somfy Names and IP Addresses - - - - - - - - - - - - - - - + + + + + + + + +
NameIP/hostnameUsernamePassword Manage
+
+
OpenHAB Names and IP Addresses + +
+ @@ -640,55 +560,47 @@ - - - - - - + + + + + - - - - - - + + + + + + ng-click="addOpenHABtoSettings(newopenhabname, newopenhabip, newopenhabport, newsopenhabusername, newopenhabpassword, newopenhabsecure)">Add + -
Name
+
FHEM Names and IP Addresses + +
+ @@ -702,61 +614,49 @@ - - - - - - - + + + + + + - - - - - - - + + + + + + + ng-click="addFhemtoSettings(newfhemname, newfhemip, newfhemport, newsfhemusername, newfhempassword, newfhemwebhook, newfhemsecure)">Add + -
Name
+
Mozilla IOT Names and IP Addresses + +
+ @@ -769,55 +669,46 @@ - - - - - - + + + + + - - - - - - + + + + + + ng-click="addMozIottoSettings(newmoziotname, newmoziotip, newmoziotport, newsmoziotusername, newmoziotpassword, newmoziotwebhook, newmoziotsecure)">Add + -
Name
+
+
HomeGenie Names and IP Addresses + +
+ @@ -830,54 +721,48 @@ - - - - - - + + + + + + ng-click="removeHomeGenietoSettings(homegenie.name, homegenie.ip)">Del + - - - - - - + + + + + + ng-click="addHomeGenietoSettings(newhomegeniename, newhomegenieip, newhomegenieport, newshomegenieusername, newhomegeniepassword, newhomegeniewebhook, newhomegeniesecure)">Add + -
Name
+
+
Nest + + + + + + +
+ @@ -885,91 +770,76 @@ - - - - - -
UsernameTemp Farenheit
{{bridge.settings.farenheit}}
{{bridge.settings.farenheit}}
+
LIFX Support {{bridge.settings.lifxconfigured}} {{bridge.settings.lifxconfigured}}
Broadlink Support {{bridge.settings.broadlinkconfigured}} {{bridge.settings.broadlinkconfigured}}
Emulate Hue Hub Version
Emulate MAC
(used in bridge-id, uuid, etc.
- leave blank unless needed)
Button Press/Call Item
Loop Sleep Interval (ms)
Log Messages to Buffer
UPNP Original (simple version) {{bridge.settings.upnporiginal}} {{bridge.settings.upnporiginal}}
Trace UPNP Calls {{bridge.settings.traceupnp}} {{bridge.settings.traceupnp}}
Trace State Changes {{bridge.settings.tracestate}} {{bridge.settings.tracestate}}
UPNP Send Delay
ID Seed (start numbering from this value)
My Echo URL
@@ -978,8 +848,7 @@

- Bridge Settings Backup + Bridge Settings Backup

@@ -990,11 +859,10 @@ Settings File Name
- +
-
@@ -1005,13 +873,13 @@
- - -
-
- Upload Successful + +
+
+
+ Upload Successful @@ -1024,8 +892,7 @@
{{backup}} - +