From 84fb79f9d95b3706dea3000bd89ebe8b8e804c18 Mon Sep 17 00:00:00 2001 From: Admin Date: Tue, 8 Nov 2016 11:27:43 -0600 Subject: [PATCH] Fixed issue with "Test Dim" button not presenting the value selector when there was a body with a dim command. Added ability to specifically set the web server address port. Fixes #225 Fixes #217 --- README.md | 16 +++++++++------- pom.xml | 2 +- .../HABridge/BridgeSettingsDescriptor.java | 8 ++++++++ .../java/com/bwssystems/HABridge/HABridge.java | 2 +- src/main/resources/public/scripts/app.js | 6 +----- src/main/resources/public/views/system.html | 7 +++++++ 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 226d797..a9a53f2 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Then locate the jar and start the server with: ATTENTION: This requires JDK 1.8 to run ``` -java -jar ha-bridge-3.2.1.jar +java -jar ha-bridge-3.2.2.jar ``` ### Automation on Linux systems To have this configured and running automatically there are a few resources to use. One is using Docker and a docker container has been built for this and can be gotten here: https://github.com/aptalca/docker-ha-bridge @@ -38,7 +38,7 @@ After=network.target [Service] Type=simple -ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/amazon-echo/data/habridge.config /home/pi/amazon-echo/ha-bridge-3.2.1.jar +ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/amazon-echo/data/habridge.config /home/pi/amazon-echo/ha-bridge-3.2.2.jar [Install] WantedBy=multi-user.target @@ -46,11 +46,11 @@ WantedBy=multi-user.target Basic script setup to run the bridge on a pi. -Create the directory and make sure that ha-bridge-3.2.1.jar is in your /home/pi/habridge directory. +Create the directory and make sure that ha-bridge-3.2.2.jar is in your /home/pi/habridge directory. ``` pi@raspberrypi:~ $ mkdir habridge pi@raspberrypi:~ $ cd habridge -pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v3.2.1/ha-bridge-3.2.1.jar +pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v3.2.2/ha-bridge-3.2.2.jar ``` Edit the shell script for starting: ``` @@ -60,7 +60,7 @@ Then cut and past this, modify any locations that are not correct ``` cd /home/pi/habridge rm /home/pi/habridge/habridge-log.txt -nohup java -jar /home/pi/habridge/ha-bridge-3.2.1.jar > /home/pi/habridge/habridge-log.txt 2>&1 & +nohup java -jar /home/pi/habridge/ha-bridge-3.2.2.jar > /home/pi/habridge/habridge-log.txt 2>&1 & chmod 777 /home/pi/habridge/habridge-log.txt ``` Exit and save the file with ctrl-X and follow the prompts and then execute on the command line: @@ -108,6 +108,8 @@ The default location for the configuration file to contain the settings for the The default location for the db to contain the devices as they are added is "data/devices.db". If you would like a different filename or directory, specify `/ explicitly. #### UPNP IP Address The server defaults to the first available address on the host if this is not given. This default may NOT be the correct IP that is your public IP for your host on the network. It is best to set this parameter to not have discovery issues. Replace this value with the server ipv4 address you would like to use as the address that any upnp device will call after discovery. +#### Web Server IP Address +The server defaults to all interfaces on the machine (0.0.0.0). Replace this value with the server ipv4 address you would like to use as the address that will bind to a specific ip address on an interface if you would like. This is only necessary if you want to isolate how access is handled to the web UI. #### Web Server Port The server defaults to running on port 80. To override what the default is, specify a different number. ATTENTION: If you want to use any of the apps made for the Hue to control this bridge, you should keep this port set to 80. #### UPNP Response Port @@ -298,8 +300,8 @@ Dim a light | "Dim the " Brighten a light | "Brighten the " Set a light brightness to a certain percentage | "Set to 50%" Dim/Brighten lights by a certain percentage | "Dim/Brighten by 50%" -Turn on/off all lights in room | “Turn on/off lights in " -Turn on/off all lights | “Turn on/off all of the lights” +Turn on/off all lights in room | “Turn on/off lights in " +Turn on/off all lights | “Turn on/off all of the lightsâ€� To see what Home thinks you said, you can ask "Hey Google, What did I say?" or check the history in the app. diff --git a/pom.xml b/pom.xml index e0d083c..bf0d7ff 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.bwssystems.HABridge ha-bridge - 3.2.1 + 3.2.2 jar HA Bridge diff --git a/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java b/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java index d9b598a..20e4e5f 100644 --- a/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java +++ b/src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java @@ -33,6 +33,7 @@ public class BridgeSettingsDescriptor { private Map whitelist; private boolean settingsChanged; private String myechourl; + private String webaddress; public BridgeSettingsDescriptor() { super(); @@ -47,6 +48,7 @@ public class BridgeSettingsDescriptor { this.whitelist = null; this.settingsChanged = false; this.myechourl = "echo.amazon.com/#cards"; + this.webaddress = "0.0.0.0"; } public String getUpnpConfigAddress() { return upnpconfigaddress; @@ -216,6 +218,12 @@ public class BridgeSettingsDescriptor { public void setMyechourl(String myechourl) { this.myechourl = myechourl; } + public String getWebaddress() { + return webaddress; + } + public void setWebaddress(String webaddress) { + this.webaddress = webaddress; + } public Boolean isValidVera() { if(this.getVeraAddress() == null || this.getVeraAddress().getDevices().size() <= 0) return false; diff --git a/src/main/java/com/bwssystems/HABridge/HABridge.java b/src/main/java/com/bwssystems/HABridge/HABridge.java index bc575de..1036d5e 100644 --- a/src/main/java/com/bwssystems/HABridge/HABridge.java +++ b/src/main/java/com/bwssystems/HABridge/HABridge.java @@ -56,7 +56,7 @@ public class HABridge { bridgeSettings.buildSettings(); log.info("HA Bridge initializing...."); // sparkjava config directive to set ip address for the web server to listen on - // ipAddress("0.0.0.0"); // not used + ipAddress(bridgeSettings.getBridgeSettingsDescriptor().getWebaddress()); // sparkjava config directive to set port for the web server to listen on port(bridgeSettings.getBridgeSettingsDescriptor().getServerPort()); // sparkjava config directive to set html static file location for Jetty diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js index face627..b432309 100644 --- a/src/main/resources/public/scripts/app.js +++ b/src/main/resources/public/scripts/app.js @@ -769,11 +769,7 @@ app.controller('ViewingController', function ($scope, $location, $http, $window, (type == "off" && (bridgeService.aContainsB(device.offUrl, "${intensity.byte}") || bridgeService.aContainsB(device.offUrl, "${intensity.percent}") || bridgeService.aContainsB(device.offUrl, "${intensity.math("))) || - (type == "dim" && (bridgeService.aContainsB(device.dimUrl, "${intensity.byte}") || - bridgeService.aContainsB(device.dimUrl, "${intensity.percent}") || - bridgeService.aContainsB(device.dimUrl, "${intensity.math(") || - bridgeService.aContainsB(device.deviceType, "passthru") || - bridgeService.aContainsB(device.mapType, "hueDevice"))))) { + (type == "dim"))) { $scope.bridge.device = device; $scope.bridge.type = type; ngDialog.open({ diff --git a/src/main/resources/public/views/system.html b/src/main/resources/public/views/system.html index 56aa9c2..dbf10d6 100644 --- a/src/main/resources/public/views/system.html +++ b/src/main/resources/public/views/system.html @@ -82,6 +82,13 @@ ng-model="bridge.settings.upnpconfigaddress" placeholder="192.168.1.1"> + + Web Server IP Address + + Web Server Port