Skip to content

Commit

Permalink
Fixed closing homes to actually call the close on the homes. Updated the
Browse files Browse the repository at this point in the history
lowest setting on the test dim function to b 1.

Fixes #438
Fixes #440
  • Loading branch information
bwssytems committed Feb 5, 2017
1 parent 6b3ae1b commit 3016712
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 19 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ ATTENTION: This requires JDK 1.8 to run
ATTENTION: Due to port 80 being the default, Linux restricts this to super user. Use the instructions below.

```
java -jar ha-bridge-4.1.3.jar
java -jar ha-bridge-4.1.4.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

Create the directory and make sure that ha-bridge-4.1.3.jar is in your /home/pi/habridge directory.
Create the directory and make sure that ha-bridge-4.1.4.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/v4.1.3/ha-bridge-4.1.3.jar
pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v4.1.4/ha-bridge-4.1.4.jar
```
Create the directory and make sure that ha-bridge-4.1.3.jar is in your /home/pi/habridge directory.
Create the directory and make sure that ha-bridge-4.1.4.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/v4.1.3/ha-bridge-4.1.3.jar
pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v4.1.4/ha-bridge-4.1.4.jar
```
#### System Control Setup on a pi (preferred)
For next gen Linux systems (this includes the Raspberry Pi), here is a systemctl unit file that you can install. Here is a link on how to do this: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
Expand All @@ -69,7 +69,7 @@ After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.1.3.jar
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.1.4.jar
[Install]
WantedBy=multi-user.target
Expand Down Expand Up @@ -104,7 +104,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 -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.1.3.jar > /home/pi/habridge/habridge-log.txt 2>&1 &
nohup java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.1.4.jar > /home/pi/habridge/habridge-log.txt 2>&1 &
chmod 777 /home/pi/habridge/habridge-log.txt
```
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId>
<version>4.1.3</version>
<version>4.1.4</version>
<packaging>jar</packaging>

<name>HA Bridge</name>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/bwssystems/HABridge/HABridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public static void main(String[] args) {
bridgeSettings.save(bridgeSettings.getBridgeSettingsDescriptor());
homeManager.closeHomes();
udpSender.closeResponseSocket();
udpSender = null;
}
bridgeSettings.getBridgeControl().setReinit(false);
stop();
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/bwssystems/HABridge/HomeManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bwssystems.HABridge;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -96,6 +97,11 @@ public ResourceHandler findResource(String type) {
}

public void closeHomes() {

Collection<Home> theHomes = homeList.values();
for(Home aHome : theHomes) {
aHome.closeHome();
}
homeList.clear();
homeList = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public Object getItems(String type) {
public void closeHome() {
if(theSession != null) {
theNest.endNestSession();
theNest = null;
theSession = null;
nestItems = null;
}
theNest = null;
theSession = null;
nestItems = null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,11 @@ public void setHalAddress(NamedIP halAddress) {
this.halAddress = halAddress;
}

public void closeInfo() {
if(httpClient != null)
httpClient.closeHandler();
httpClient = null;
halAddress = null;
theToken = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,14 @@ public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String
public void closeHome() {
if(!validHass)
return;
if(hassMap == null)
return;
Iterator<String> keys = hassMap.keySet().iterator();
while(keys.hasNext()) {
String key = keys.next();
hassMap.get(key).closeClient();
}

hassMap = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,6 @@ public List<State> getDevices() {

protected void closeClient() {
anHttpHandler.closeHandler();
anHttpHandler = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ public Object getItems(String type) {

@Override
public void closeHome() {
anHttpHandler.closeHandler();
if(anHttpHandler != null)
anHttpHandler.closeHandler();
anHttpHandler = null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ public Home createHome(BridgeSettingsDescriptor bridgeSettings) {
public void closeHome() {
if(!validHue)
return;
if(hues == null)
return;
Iterator<String> keys = hues.keySet().iterator();
while(keys.hasNext()) {
String key = keys.next();
hues.get(key).closeHue();;
}
hues = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ public void shutdown() {
} catch (MqttException e) {
log.warn("Could not disconnect MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp());
}
myClient = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void closeHome() {
handlers.get(key).shutdown();
}
}
handlers = null;
}

public MQTTHandler getMQTTHandler(String aName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public Home createHome(BridgeSettingsDescriptor bridgeSettings) {

@Override
public void closeHome() {
// TODO Auto-generated method stub

veras = null;
}
}
8 changes: 4 additions & 4 deletions src/main/resources/public/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
$scope.slider = {
value: 100,
options: {
floor: 0,
floor: 1,
ceil: 100,
showSelectionBar: true
}
Expand All @@ -1154,8 +1154,8 @@ app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
$scope.valueType = "percentage";
$scope.changeScale = function () {
if($scope.valueType === "raw") {
$scope.slider.options.ceil = 255;
$scope.slider.value = 255;
$scope.slider.options.ceil = 254;
$scope.slider.value = 254;
}
else {
$scope.slider.options.ceil = 100;
Expand All @@ -1164,7 +1164,7 @@ app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
};
$scope.setValue = function () {
ngDialog.close('ngdialog1');
var theValue = 0;
var theValue = 1;
if($scope.valueType === "percentage")
theValue = Math.round(($scope.slider.value * .01) * 255);
else
Expand Down

0 comments on commit 3016712

Please sign in to comment.