Compare commits

...

3 Commits

Author SHA1 Message Date
bwssystems
e7acff9f54 Fixed MQTT initialization error with maven build inclusion. Added URI
encoder to handle URI calls with URL characters.

Fixes #250
Fixes #251
Fixes #252
2016-11-19 14:12:32 -06:00
Admin
9c4b428c86 Added updates to README and also the latest release includes more
constructs for itmes and device buttons for delay and count.

Fixes #132
2016-11-18 15:34:20 -06:00
BWS Systems
80b3e87e44 remove harmony user and pass
These parameters are not needed anymore.
2016-11-18 15:20:56 -06:00
3 changed files with 30 additions and 14 deletions

View File

@@ -23,16 +23,16 @@ Then locate the jar and start the server with:
ATTENTION: This requires JDK 1.8 to run ATTENTION: This requires JDK 1.8 to run
``` ```
java -jar ha-bridge-3.2.2.jar java -jar ha-bridge-3.5.0.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-3.2.2.jar is in your /home/pi/habridge directory. Create the directory and make sure that ha-bridge-3.5.0.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/v3.2.2/ha-bridge-3.2.2.jar pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v3.5.0/ha-bridge-3.5.0.jar
``` ```
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
@@ -44,7 +44,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-3.2.2.jar ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-3.5.0.jar
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
@@ -61,7 +61,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-3.2.2.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-3.5.0.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
``` ```
Exit and save the file with ctrl-X and follow the prompts and then execute on the command line: Exit and save the file with ctrl-X and follow the prompts and then execute on the command line:
@@ -120,9 +120,9 @@ Provide IP Addresses of your Veras that you want to utilize with the bridge. Als
#### Harmony Names and IP Addresses #### Harmony Names and IP Addresses
Provide IP Addresses of your Harmony Hubs that you want to utilize with the bridge. Also, give a meaningful name to each one so it is easy to decipher in the helper tab. When these names and IP's are given, the bridge will be able to control the activity or buttons by the call it receives and send it to the target Harmony Hub and activity/button you configure. Provide IP Addresses of your Harmony Hubs that you want to utilize with the bridge. Also, give a meaningful name to each one so it is easy to decipher in the helper tab. When these names and IP's are given, the bridge will be able to control the activity or buttons by the call it receives and send it to the target Harmony Hub and activity/button you configure.
#### Harmony Username #### Harmony Username
The user name of the MyHarmony.com account for the Harmony Hub. This needs to be given if you are using the Harmony Hub features. depracated
#### Harmony Password #### Harmony Password
The password for the user name of the MyHarmony.com account for the Harmony Hub. This needs to be given if you are using the Harmony Hub Features. depracated
#### Hue Names and IP Addresses #### Hue Names and IP Addresses
Provide IP Addresses of your Hue Bridges that you want to proxy through the bridge. Also, give a meaningful name to each one so it is easy to decipher in the helper tab. When these names and IP's are given, the bridge will passthru the call it receives to the target Hue and device you configure. Provide IP Addresses of your Hue Bridges that you want to proxy through the bridge. Also, give a meaningful name to each one so it is easy to decipher in the helper tab. When these names and IP's are given, the bridge will passthru the call it receives to the target Hue and device you configure.
@@ -131,6 +131,8 @@ Don't forget - You will need to push the link button when you got to the Hue Tab
Provide IP Addresses of your HAL Systems that you want to utilize with the bridge. Also, give a meaningful name to each one so it is easy to decipher in the helper tab. When these names and IP's are given, the bridge will be able to control the devices or scenes by the call it receives and send it to the target HAL and device/scene you configure. Provide IP Addresses of your HAL Systems that you want to utilize with the bridge. Also, give a meaningful name to each one so it is easy to decipher in the helper tab. When these names and IP's are given, the bridge will be able to control the devices or scenes by the call it receives and send it to the target HAL and device/scene you configure.
#### HAL Token #### HAL Token
The token you generate or give to a HAL and must be the same for all HAL's you have identified. This needs to be given if you are using the HAL features. The token you generate or give to a HAL and must be the same for all HAL's you have identified. This needs to be given if you are using the HAL features.
#### MQTT Client IDs and IP Addresses
Provide Client ID and IP Addresses and ports of your MQTT Brokers that you want to utilize with the bridge. Also, you can provide the username and password if you have secured yourMQTT broker which is optional. When these Client ID and IP's are given, the bridge will be able to publish mqtt messages by the call it receives and send it to the target MQTT Broker you configure. The MQTT Messages Tab will become available to help you build messages.
#### Nest Username #### Nest Username
The user name of the home.nest.com account for the Nest user. This needs to be given if you are using the Nest features. There is no need to give any ip address or host information as this contacts your cloud account. The user name of the home.nest.com account for the Nest user. This needs to be given if you are using the Nest features. There is no need to give any ip address or host information as this contacts your cloud account.
#### Nest Password #### Nest Password
@@ -194,11 +196,11 @@ tcp://192.168.5.5:110000/0x
``` ```
#### Multiple Call Construct #### Multiple Call Construct
Also available is the ability to specify multiple commands in the On URL, Dim URL and Off URL areas by adding Json constructs listed here. This is only for the types of tcp, udp, http, https or a new exec type. Also available is the ability to specify multiple commands in the On URL, Dim URL and Off URL areas by adding Json constructs listed here. This is only for the types of tcp, udp, http, https or a new exec type. Also within the item format you can specify delay in milliseconds and count per item. These new paramters work on device buttons for the Harmony as well.
Format Example in the URL areas: Format Example in the URL areas:
``` ```
[{"item":"http://192.168.1.1:8180/do/this/thing"}, [{"item":"http://192.168.1.1:8180/do/this/thing"},
{"item":"http://192.168.1.1:8180/do/the/next/thing"}, {"item":"http://192.168.1.1:8180/do/the/next/thing","delay":1000,"count":2},
"item":"http://192.168.1.1:8180/do/another/thing"}] "item":"http://192.168.1.1:8180/do/another/thing"}]

View File

@@ -5,7 +5,7 @@
<groupId>com.bwssystems.HABridge</groupId> <groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId> <artifactId>ha-bridge</artifactId>
<version>3.5.0</version> <version>3.5.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>HA Bridge</name> <name>HA Bridge</name>
@@ -192,6 +192,12 @@
<include>**</include> <include>**</include>
</includes> </includes>
</filter> </filter>
<filter>
<artifact>org.eclipse.paho:org.eclipse.paho.client.mqttv3</artifact>
<includes>
<include>**</include>
</includes>
</filter>
</filters> </filters>
<transformers> <transformers>
<transformer <transformer

View File

@@ -66,6 +66,8 @@ import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.Socket; import java.net.Socket;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@@ -1125,6 +1127,7 @@ public class HueMulator implements HueErrorStringSet {
protected String doHttpRequest(String url, String httpVerb, String contentType, String body, NameValue[] headers) { protected String doHttpRequest(String url, String httpVerb, String contentType, String body, NameValue[] headers) {
HttpUriRequest request = null; HttpUriRequest request = null;
String theContent = null; String theContent = null;
URI theURI = null;
ContentType parsedContentType = null; ContentType parsedContentType = null;
StringEntity requestBody = null; StringEntity requestBody = null;
if(contentType != null && contentType.length() > 0) { if(contentType != null && contentType.length() > 0) {
@@ -1132,17 +1135,22 @@ public class HueMulator implements HueErrorStringSet {
if(body != null && body.length() > 0) if(body != null && body.length() > 0)
requestBody = new StringEntity(body, parsedContentType); requestBody = new StringEntity(body, parsedContentType);
} }
try {
theURI = new URI(url);
} catch (URISyntaxException e1) {
log.warn("Error creating URI http request: " + url + " with message: " + e1.getMessage());
return null;
}
try { try {
if(HttpGet.METHOD_NAME.equalsIgnoreCase(httpVerb) || httpVerb == null) { if(HttpGet.METHOD_NAME.equalsIgnoreCase(httpVerb) || httpVerb == null) {
request = new HttpGet(url); request = new HttpGet(theURI);
}else if(HttpPost.METHOD_NAME.equalsIgnoreCase(httpVerb)){ }else if(HttpPost.METHOD_NAME.equalsIgnoreCase(httpVerb)){
HttpPost postRequest = new HttpPost(url); HttpPost postRequest = new HttpPost(theURI);
if(requestBody != null) if(requestBody != null)
postRequest.setEntity(requestBody); postRequest.setEntity(requestBody);
request = postRequest; request = postRequest;
}else if(HttpPut.METHOD_NAME.equalsIgnoreCase(httpVerb)){ }else if(HttpPut.METHOD_NAME.equalsIgnoreCase(httpVerb)){
HttpPut putRequest = new HttpPut(url); HttpPut putRequest = new HttpPut(theURI);
if(requestBody != null) if(requestBody != null)
putRequest.setEntity(requestBody); putRequest.setEntity(requestBody);
request = putRequest; request = putRequest;