diff --git a/README.md b/README.md
index 218d825..3c148e1 100644
--- a/README.md
+++ b/README.md
@@ -513,8 +513,8 @@ contentBodyOff | string | This is the content body that you would like to send w
{
"name" : "bedroom light",
"deviceType" : "switch",
- "onUrl" : [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=41","type":"veraDevice"}],
- "offUrl" : [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=41","type":"veraDevice"}]
+ "onUrl" : "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=41\",\"type\":\"veraDevice\"}]",
+ "offUrl" : "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=41\",\"type\":\"veraDevice\"}]"
}
```
#### Dimming Control Example
@@ -524,8 +524,8 @@ e.g.
{
"name": "entry light",
"deviceType": "switch",
- "offUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=31","type":"veraDevice"}],
- "onUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=31&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.percent}","type":"veraDevice"}]
+ "offUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=31\",\"type\":\"veraDevice\"}]",
+ "onUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=31&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.percent}\",\"type\":\"veraDevice\"}]"
}
```
See the echo's documentation for the dimming phrase.
@@ -537,8 +537,8 @@ e.g.
{
"name": "Thermostat,
"deviceType": "custom",
- "offUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=10","type":"veraDevice"}],
- "onUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=10&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.math(X/4)}","type":"veraDevice"}]
+ "offUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=10\",\"type\":\"veraDevice\"}]",
+ "onUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=10&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.math(X/4)}\",\"type\":\"veraDevice\"}]"
}
```
See the echo's documentation for the dimming phrase.
@@ -550,8 +550,8 @@ e.g:
{
"name": "test device",
"deviceType": "custom",
- "offUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=31","httpVerb":"POST","contentType" : "application/json","httpBody" : "{\"fooBar\":\"baz_off\"}],
- "onUrl": [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=31&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.percent}","type":"httpDevice","httpVerb":"POST","contentType" : "application/json","httpBody" : "{\"fooBar\":\"baz_on\"}]
+ "offUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=31\",\"httpVerb\":\"POST\",\"contentType\" : \"application/json\",\"httpBody\" : \"{\"fooBar\":\"baz_off\"}]",
+ "onUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&DeviceNum=31&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=${intensity.percent}\",\"type\":\"httpDevice\",\"httpVerb\":\"POST\",\"contentType\" : \"application/json\",\"httpBody\" : \"{\"fooBar\":\"baz_on\"}]"
}
```
#### Custom Usage URLs Example
@@ -560,8 +560,8 @@ Anything that takes an action as a result of an HTTP request will probably work
{
"name": "night mode",
"deviceType": ""custom",
- "offUrl": [{"item":"http://192.168.1.201:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=SetHouseMode&Mode=1","type":"httpDevice"}],
- "onUrl": [{"item":"http://192.168.1.201:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=SetHouseMode&Mode=3","type":"httpDevice"}]
+ "offUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=SetHouseMode&Mode=1\",\"type\":\"httpDevice\"}]",
+ "onUrl": "[{\"item\":\"http://192.168.1.201:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=SetHouseMode&Mode=3\",\"type\":\"httpDevice\"}]"
}
```
Here is a UDP example that can send binary data.
@@ -569,8 +569,8 @@ Here is a UDP example that can send binary data.
{
"name": "UDPPacket",
"deviceType": "custom",
- "offUrl": [{"item":"udp://192.168.1.1:8899/0x460055","type":"udpDevice"}],
- "onUrl": [{"item":"udp://192.168.1.1:8899/0x450055","type":"udpDevice"}]
+ "offUrl": "[{\"item\":\"udp://192.168.1.1:8899/0x460055\",\"type\":\"udpDevice\"}]",
+ "onUrl": "[{\"item\":\"udp://192.168.1.1:8899/0x450055\",\"type\":\"udpDevice\"}]"
}
```
#### Response
@@ -629,8 +629,8 @@ contentBodyOff | string | This is the content body that you would like to send w
"id" : "6789",
"name" : "table light",
"deviceType" : "switch",
- "onUrl" : [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=41","type":"veraDevice"}],
- "offUrl" : [{"item":"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=41","type":"veraDevice"}]
+ "onUrl" : "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=41\",\"type\":\"veraDevice\"}]",
+ "offUrl" : "[{\"item\":\"http://192.168.1.201:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=41\",\"type\":\"veraDevice\"}]"
}
```
#### Response
diff --git a/pom.xml b/pom.xml
index d99df93..927d11e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.bwssystems.HABridge
ha-bridge
- 4.5.0
+ 4.5.0a
jar
HA Bridge
diff --git a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
index eb16b11..a1dfc1c 100644
--- a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
+++ b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
@@ -126,7 +126,7 @@ public class HueMulator {
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
response.type("application/json");
response.status(HttpStatus.SC_OK);
- log.debug("put to groups API from " + request.ip() + " user " + request.params(":userid") + " with body " + request.body());
+ log.debug("put action to groups API from " + request.ip() + " user " + request.params(":userid") + " with body " + request.body());
return "[{\"error\":{\"address\": \"/groups/0/action/scene\", \"type\":7, \"description\": \"invalid value, dummy for parameter, scene\"}}]";
});
// http://ip_address:port/api/{userId}/scenes returns json objects of
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/hal/HalHome.java b/src/main/java/com/bwssystems/HABridge/plugins/hal/HalHome.java
index 0efe396..05f0c0a 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/hal/HalHome.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/hal/HalHome.java
@@ -13,8 +13,15 @@ import com.bwssystems.HABridge.BridgeSettings;
import com.bwssystems.HABridge.Home;
import com.bwssystems.HABridge.NamedIP;
import com.bwssystems.HABridge.api.CallItem;
+import com.bwssystems.HABridge.api.NameValue;
+import com.bwssystems.HABridge.api.hue.HueError;
+import com.bwssystems.HABridge.api.hue.HueErrorResponse;
import com.bwssystems.HABridge.dao.DeviceDescriptor;
+import com.bwssystems.HABridge.hue.BrightnessDecode;
+import com.bwssystems.HABridge.hue.DeviceDataDecode;
import com.bwssystems.HABridge.hue.MultiCommandUtil;
+import com.bwssystems.HABridge.hue.TimeDecode;
+import com.google.gson.Gson;
public class HalHome implements Home {
private static final Logger log = LoggerFactory.getLogger(HalHome.class);
@@ -30,7 +37,7 @@ public class HalHome implements Home {
public Object getItems(String type) {
if(!validHal)
return null;
- log.debug("consolidating devices for hues");
+ log.debug("consolidating devices for HALs");
List theResponse = null;
Iterator keys = hals.keySet().iterator();
List deviceList = new ArrayList();
@@ -106,8 +113,41 @@ public class HalHome implements Home {
@Override
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
- // Not a device handler
- return null;
+ String responseString = null;
+ String theUrl = anItem.getItem().getAsString();
+ if(theUrl != null && !theUrl.isEmpty () && theUrl.contains("http://")) {
+ String intermediate = theUrl.substring(theUrl.indexOf("://") + 3);
+ String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
+// String theUrlBody = intermediate.substring(intermediate.indexOf('/') + 1);
+ String hostAddr = null;
+// String port = null;
+ if (hostPortion.contains(":")) {
+ hostAddr = hostPortion.substring(0, intermediate.indexOf(':'));
+// port = hostPortion.substring(intermediate.indexOf(':') + 1);
+ } else
+ hostAddr = hostPortion;
+ log.debug("executing HUE api request to Http "
+ + (anItem.getHttpVerb() == null ? "GET" : anItem.getHttpVerb()) + ": "
+ + anItem.getItem().getAsString());
+
+ String anUrl = BrightnessDecode.calculateReplaceIntensityValue(theUrl,
+ intensity, targetBri, targetBriInc, false);
+ anUrl = DeviceDataDecode.replaceDeviceData(anUrl, device);
+ anUrl = TimeDecode.replaceTimeValue(anUrl);
+
+ for (Map.Entry entry : hals.entrySet())
+ {
+ if(entry.getValue().getHalAddress().getIp().equals(hostAddr)) {
+ if (entry.getValue().deviceCommand(anUrl) == null) {
+ log.warn("Error on calling hal to change device state: " + anUrl);
+ responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
+ "Error on calling url to change device state", "/lights/"
+ + lightId + "state", null, null).getTheErrors(), HueError[].class);
+ }
+ }
+ }
+ }
+ return responseString;
}
@Override
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/hal/HalInfo.java b/src/main/java/com/bwssystems/HABridge/plugins/hal/HalInfo.java
index 7f13862..4da5514 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/hal/HalInfo.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/hal/HalInfo.java
@@ -8,6 +8,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.bwssystems.HABridge.NamedIP;
+import com.bwssystems.HABridge.api.hue.HueError;
+import com.bwssystems.HABridge.api.hue.HueErrorResponse;
import com.bwssystems.HABridge.plugins.http.HTTPHandler;
import com.bwssystems.HABridge.util.TextStringFormatter;
import com.google.gson.Gson;
@@ -177,6 +179,12 @@ public class HalInfo {
return deviceList;
}
+ public String deviceCommand(String theUrl) {
+ String theData = null;
+ theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
+ return theData;
+ }
+
public NamedIP getHalAddress() {
return halAddress;
}
diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js
index f98bcce..b6f387e 100644
--- a/src/main/resources/public/scripts/app.js
+++ b/src/main/resources/public/scripts/app.js
@@ -1285,11 +1285,11 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
}
}
};
- $scope.addHarmonytoSettings = function (newharmonyname, newharmonyip) {
+ $scope.addHarmonytoSettings = function (newharmonyname, newharmonyip, newharmonywebhook) {
if($scope.bridge.settings.harmonyaddress === undefined || $scope.bridge.settings.harmonyaddress === null) {
$scope.bridge.settings.harmonyaddress = { devices: [] };
}
- var newharmony = {name: newharmonyname, ip: newharmonyip }
+ var newharmony = {name: newharmonyname, ip: newharmonyip, webhook: newharmonywebhook}
$scope.bridge.settings.harmonyaddress.devices.push(newharmony);
$scope.newharmonyname = null;
$scope.newharmonyip = null;
diff --git a/src/main/resources/public/views/system.html b/src/main/resources/public/views/system.html
index 811af09..f5f5bdd 100644
--- a/src/main/resources/public/views/system.html
+++ b/src/main/resources/public/views/system.html
@@ -147,7 +147,7 @@
| {{harmony.ip}} |
{{harmony.webhook}} |
|
+ ng-click="removeHarmonytoSettings(harmony.name, harmony.ip)">Del
|