mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-19 16:41:53 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3016712ad8 | ||
|
|
6b3ae1b971 | ||
|
|
71258c7e52 | ||
|
|
0ce23c0f00 | ||
|
|
1c7260600a | ||
|
|
f1592a1998 |
16
README.md
16
README.md
@@ -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.
|
ATTENTION: Due to port 80 being the default, Linux restricts this to super user. Use the instructions below.
|
||||||
|
|
||||||
```
|
```
|
||||||
java -jar ha-bridge-4.1.1.jar
|
java -jar ha-bridge-4.1.4.jar
|
||||||
```
|
```
|
||||||
### Automation on Linux systems
|
### 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
|
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.1.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:~ $ mkdir habridge
|
||||||
pi@raspberrypi:~ $ cd habridge
|
pi@raspberrypi:~ $ cd habridge
|
||||||
|
|
||||||
pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v4.1.1/ha-bridge-4.1.1.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.1.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:~ $ mkdir habridge
|
||||||
pi@raspberrypi:~ $ cd habridge
|
pi@raspberrypi:~ $ cd habridge
|
||||||
pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v4.1.1/ha-bridge-4.1.1.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)
|
#### 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
|
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
|
||||||
@@ -69,7 +69,7 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
|
|
||||||
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.1.1.jar
|
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.1.4.jar
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
@@ -104,7 +104,7 @@ Then cut and past this, modify any locations that are not correct
|
|||||||
```
|
```
|
||||||
cd /home/pi/habridge
|
cd /home/pi/habridge
|
||||||
rm /home/pi/habridge/habridge-log.txt
|
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.1.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
|
chmod 777 /home/pi/habridge/habridge-log.txt
|
||||||
```
|
```
|
||||||
@@ -692,7 +692,7 @@ This call returns a null json "{}".
|
|||||||
### Get HA Bridge Version
|
### Get HA Bridge Version
|
||||||
Get current version of the HA bridge software.
|
Get current version of the HA bridge software.
|
||||||
```
|
```
|
||||||
GET http://host:port/api/devices/habridge/version
|
GET http://host:port/system/habridge/version
|
||||||
```
|
```
|
||||||
#### Response
|
#### Response
|
||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.bwssystems.HABridge</groupId>
|
<groupId>com.bwssystems.HABridge</groupId>
|
||||||
<artifactId>ha-bridge</artifactId>
|
<artifactId>ha-bridge</artifactId>
|
||||||
<version>4.1.1</version>
|
<version>4.1.4</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ public class HABridge {
|
|||||||
bridgeSettings.save(bridgeSettings.getBridgeSettingsDescriptor());
|
bridgeSettings.save(bridgeSettings.getBridgeSettingsDescriptor());
|
||||||
homeManager.closeHomes();
|
homeManager.closeHomes();
|
||||||
udpSender.closeResponseSocket();
|
udpSender.closeResponseSocket();
|
||||||
|
udpSender = null;
|
||||||
}
|
}
|
||||||
bridgeSettings.getBridgeControl().setReinit(false);
|
bridgeSettings.getBridgeControl().setReinit(false);
|
||||||
stop();
|
stop();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.bwssystems.HABridge;
|
package com.bwssystems.HABridge;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -96,6 +97,11 @@ public class HomeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void closeHomes() {
|
public void closeHomes() {
|
||||||
|
Collection<Home> theHomes = homeList.values();
|
||||||
|
for(Home aHome : theHomes) {
|
||||||
|
aHome.closeHome();
|
||||||
|
}
|
||||||
|
homeList.clear();
|
||||||
|
homeList = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,19 +220,22 @@ public class DeviceDescriptor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsType(String aType) {
|
public boolean containsType(String aType) {
|
||||||
if(this.mapType.contains(aType))
|
if(aType == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(this.mapType != null && this.mapType.contains(aType))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(this.deviceType.contains(aType))
|
if(this.deviceType != null && this.deviceType.contains(aType))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(this.onUrl.contains(aType))
|
if(this.onUrl != null && this.onUrl.contains(aType))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(this.dimUrl.contains(aType))
|
if(this.dimUrl != null && this.dimUrl.contains(aType))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(this.offUrl.contains(aType))
|
if(this.offUrl != null && this.offUrl.contains(aType))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -94,11 +94,11 @@ public class NestHome implements com.bwssystems.HABridge.Home {
|
|||||||
public void closeHome() {
|
public void closeHome() {
|
||||||
if(theSession != null) {
|
if(theSession != null) {
|
||||||
theNest.endNestSession();
|
theNest.endNestSession();
|
||||||
|
}
|
||||||
theNest = null;
|
theNest = null;
|
||||||
theSession = null;
|
theSession = null;
|
||||||
nestItems = null;
|
nestItems = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
||||||
|
|||||||
@@ -149,8 +149,12 @@ public class HalInfo {
|
|||||||
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
||||||
if (theData != null) {
|
if (theData != null) {
|
||||||
log.debug("GET IrData for IR Device " + theHalDevice.getHaldevicename() + " HalApiResponse - data: " + theData);
|
log.debug("GET IrData for IR Device " + theHalDevice.getHaldevicename() + " HalApiResponse - data: " + theData);
|
||||||
|
try {
|
||||||
theHalApiResponse = new Gson().fromJson(theData, DeviceElements.class);
|
theHalApiResponse = new Gson().fromJson(theData, DeviceElements.class);
|
||||||
if (theHalApiResponse.getDeviceElements() == null) {
|
} catch (Exception e) {
|
||||||
|
theHalApiResponse = null;
|
||||||
|
}
|
||||||
|
if (theHalApiResponse == null || theHalApiResponse.getDeviceElements() == null) {
|
||||||
StatusDescription theStatus = new Gson().fromJson(theData, StatusDescription.class);
|
StatusDescription theStatus = new Gson().fromJson(theData, StatusDescription.class);
|
||||||
if (theStatus.getStatus() == null) {
|
if (theStatus.getStatus() == null) {
|
||||||
log.warn("Cannot get buttons for IR Device " + theHalDevice.getHaldevicename() + " for hal "
|
log.warn("Cannot get buttons for IR Device " + theHalDevice.getHaldevicename() + " for hal "
|
||||||
@@ -181,4 +185,11 @@ public class HalInfo {
|
|||||||
this.halAddress = halAddress;
|
this.halAddress = halAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void closeInfo() {
|
||||||
|
if(httpClient != null)
|
||||||
|
httpClient.closeHandler();
|
||||||
|
httpClient = null;
|
||||||
|
halAddress = null;
|
||||||
|
theToken = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,10 +151,14 @@ public class HassHome implements Home {
|
|||||||
public void closeHome() {
|
public void closeHome() {
|
||||||
if(!validHass)
|
if(!validHass)
|
||||||
return;
|
return;
|
||||||
|
if(hassMap == null)
|
||||||
|
return;
|
||||||
Iterator<String> keys = hassMap.keySet().iterator();
|
Iterator<String> keys = hassMap.keySet().iterator();
|
||||||
while(keys.hasNext()) {
|
while(keys.hasNext()) {
|
||||||
String key = keys.next();
|
String key = keys.next();
|
||||||
hassMap.get(key).closeClient();
|
hassMap.get(key).closeClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hassMap = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,5 +104,6 @@ public class HomeAssistant {
|
|||||||
|
|
||||||
protected void closeClient() {
|
protected void closeClient() {
|
||||||
anHttpHandler.closeHandler();
|
anHttpHandler.closeHandler();
|
||||||
|
anHttpHandler = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,9 @@ public class HTTPHome implements Home {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeHome() {
|
public void closeHome() {
|
||||||
|
if(anHttpHandler != null)
|
||||||
anHttpHandler.closeHandler();
|
anHttpHandler.closeHandler();
|
||||||
|
anHttpHandler = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,10 +124,13 @@ public class HueHome implements Home {
|
|||||||
public void closeHome() {
|
public void closeHome() {
|
||||||
if(!validHue)
|
if(!validHue)
|
||||||
return;
|
return;
|
||||||
|
if(hues == null)
|
||||||
|
return;
|
||||||
Iterator<String> keys = hues.keySet().iterator();
|
Iterator<String> keys = hues.keySet().iterator();
|
||||||
while(keys.hasNext()) {
|
while(keys.hasNext()) {
|
||||||
String key = keys.next();
|
String key = keys.next();
|
||||||
hues.get(key).closeHue();;
|
hues.get(key).closeHue();;
|
||||||
}
|
}
|
||||||
|
hues = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,5 +68,6 @@ public class MQTTHandler {
|
|||||||
} catch (MqttException e) {
|
} catch (MqttException e) {
|
||||||
log.warn("Could not disconnect MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp());
|
log.warn("Could not disconnect MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp());
|
||||||
}
|
}
|
||||||
|
myClient = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public class MQTTHome implements Home {
|
|||||||
handlers.get(key).shutdown();
|
handlers.get(key).shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
handlers = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MQTTHandler getMQTTHandler(String aName) {
|
public MQTTHandler getMQTTHandler(String aName) {
|
||||||
|
|||||||
@@ -49,11 +49,12 @@ public class TCPHome implements Home {
|
|||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, true);
|
|
||||||
theUrlBody = TimeDecode.replaceTimeValue(theUrlBody);
|
theUrlBody = TimeDecode.replaceTimeValue(theUrlBody);
|
||||||
if (theUrlBody.startsWith("0x")) {
|
if (theUrlBody.startsWith("0x")) {
|
||||||
|
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, true);
|
||||||
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
||||||
} else {
|
} else {
|
||||||
|
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, false);
|
||||||
sendData = theUrlBody.getBytes();
|
sendData = theUrlBody.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,11 +51,12 @@ public class UDPHome implements Home {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, true);
|
|
||||||
theUrlBody = TimeDecode.replaceTimeValue(theUrlBody);
|
theUrlBody = TimeDecode.replaceTimeValue(theUrlBody);
|
||||||
if (theUrlBody.startsWith("0x")) {
|
if (theUrlBody.startsWith("0x")) {
|
||||||
|
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, true);
|
||||||
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
||||||
} else {
|
} else {
|
||||||
|
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, false);
|
||||||
sendData = theUrlBody.getBytes();
|
sendData = theUrlBody.getBytes();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ public class VeraHome implements Home {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeHome() {
|
public void closeHome() {
|
||||||
// TODO Auto-generated method stub
|
veras = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1145,7 +1145,7 @@ app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
|
|||||||
$scope.slider = {
|
$scope.slider = {
|
||||||
value: 100,
|
value: 100,
|
||||||
options: {
|
options: {
|
||||||
floor: 0,
|
floor: 1,
|
||||||
ceil: 100,
|
ceil: 100,
|
||||||
showSelectionBar: true
|
showSelectionBar: true
|
||||||
}
|
}
|
||||||
@@ -1154,8 +1154,8 @@ app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
|
|||||||
$scope.valueType = "percentage";
|
$scope.valueType = "percentage";
|
||||||
$scope.changeScale = function () {
|
$scope.changeScale = function () {
|
||||||
if($scope.valueType === "raw") {
|
if($scope.valueType === "raw") {
|
||||||
$scope.slider.options.ceil = 255;
|
$scope.slider.options.ceil = 254;
|
||||||
$scope.slider.value = 255;
|
$scope.slider.value = 254;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$scope.slider.options.ceil = 100;
|
$scope.slider.options.ceil = 100;
|
||||||
@@ -1164,7 +1164,7 @@ app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
|
|||||||
};
|
};
|
||||||
$scope.setValue = function () {
|
$scope.setValue = function () {
|
||||||
ngDialog.close('ngdialog1');
|
ngDialog.close('ngdialog1');
|
||||||
var theValue = 0;
|
var theValue = 1;
|
||||||
if($scope.valueType === "percentage")
|
if($scope.valueType === "percentage")
|
||||||
theValue = Math.round(($scope.slider.value * .01) * 255);
|
theValue = Math.round(($scope.slider.value * .01) * 255);
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user