diff --git a/pom.xml b/pom.xml
index d3bbb79..fa5ebe7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.bwssystems.HABridge
ha-bridge
- 5.2.0RC4
+ 5.2.0RC5
jar
HA Bridge
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/fhem/FHEMHome.java b/src/main/java/com/bwssystems/HABridge/plugins/fhem/FHEMHome.java
index a26a818..21521e2 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/fhem/FHEMHome.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/fhem/FHEMHome.java
@@ -24,12 +24,15 @@ import com.bwssystems.HABridge.hue.MultiCommandUtil;
import com.bwssystems.HABridge.hue.TimeDecode;
import com.bwssystems.HABridge.plugins.http.HTTPHandler;
import com.bwssystems.HABridge.plugins.http.HTTPHome;
+import com.bwssystems.HABridge.plugins.http.HttpTestHandler;
+import com.bwssystems.fhem.test.FHEMInstanceConstructor;
import com.google.gson.Gson;
public class FHEMHome implements Home {
private static final Logger log = LoggerFactory.getLogger(FHEMHome.class);
private Map fhemMap;
private Boolean validFhem;
+ private Boolean isDevMode;
private HTTPHandler httpClient;
private boolean closed;
@@ -159,12 +162,17 @@ public class FHEMHome implements Home {
@Override
public Home createHome(BridgeSettings bridgeSettings) {
+ isDevMode = Boolean.parseBoolean(System.getProperty("dev.mode", "false"));
fhemMap = null;
validFhem = bridgeSettings.getBridgeSettingsDescriptor().isValidFhem();
log.info("FHEM Home created." + (validFhem ? "" : " No FHEMs configured."));
if(validFhem) {
fhemMap = new HashMap();
httpClient = HTTPHome.getHandler();
+ if(isDevMode) {
+ httpClient = new HttpTestHandler();
+ ((HttpTestHandler)httpClient).setTheData(FHEMInstanceConstructor.TestData);
+ }
Iterator theList = bridgeSettings.getBridgeSettingsDescriptor().getFhemaddress().getDevices().iterator();
while(theList.hasNext() && validFhem) {
NamedIP aFhem = theList.next();
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/fhem/FHEMInstance.java b/src/main/java/com/bwssystems/HABridge/plugins/fhem/FHEMInstance.java
index 7e25deb..2916eee 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/fhem/FHEMInstance.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/fhem/FHEMInstance.java
@@ -31,7 +31,6 @@ public class FHEMInstance {
}
public Boolean callCommand(String aCommand, String commandData, HTTPHandler httpClient) {
- log.debug("calling FHEM: " + theFhem.getIp() + ":" + theFhem.getPort() + aCommand);
String aUrl = null;
NameValue[] headers = null;
if(theFhem.getSecure() != null && theFhem.getSecure())
@@ -41,9 +40,11 @@ public class FHEMInstance {
if(theFhem.getUsername() != null && !theFhem.getUsername().isEmpty() && theFhem.getPassword() != null && !theFhem.getPassword().isEmpty()) {
aUrl = aUrl + theFhem.getUsername() + ":" + theFhem.getPassword() + "@";
}
- aUrl = aUrl + theFhem.getIp() + ":" + theFhem.getPort() + "/" + aCommand;
- String theData = httpClient.doHttpRequest(aUrl, HttpPost.METHOD_NAME, "text/plain", commandData, headers);
- log.debug("call Command return is: <" + theData + ">");
+ aUrl = aUrl + theFhem.getIp() + ":" + theFhem.getPort() + "/" + aCommand + "/" + commandData;
+ log.debug("calling FHEM: " + aUrl);
+ String theData = httpClient.doHttpRequest(aUrl, HttpPost.METHOD_NAME, "text/plain", null, headers);
+ if(theData != null)
+ log.debug("doHttpRequest returned data: <" + theData + ">");
return true;
}
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/http/HttpTestHandler.java b/src/main/java/com/bwssystems/HABridge/plugins/http/HttpTestHandler.java
new file mode 100644
index 0000000..276406f
--- /dev/null
+++ b/src/main/java/com/bwssystems/HABridge/plugins/http/HttpTestHandler.java
@@ -0,0 +1,20 @@
+package com.bwssystems.HABridge.plugins.http;
+
+import com.bwssystems.HABridge.api.NameValue;
+import com.bwssystems.HABridge.plugins.http.HTTPHandler;
+
+public class HttpTestHandler extends HTTPHandler {
+ private String theData;
+
+ public String getTheData() {
+ return theData;
+ }
+
+ public void setTheData(String theData) {
+ this.theData = theData;
+ }
+
+ public String doHttpRequest(String url, String httpVerb, String contentType, String body, NameValue[] headers) {
+ return theData;
+ }
+}
diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js
index 99920e0..9eb0e98 100644
--- a/src/main/resources/public/scripts/app.js
+++ b/src/main/resources/public/scripts/app.js
@@ -3874,7 +3874,7 @@ app.controller('FhemController', function ($scope, $location, bridgeService, ngD
$scope.device = bridgeService.state.device;
};
- $scope.buildDeviceUrls = function (fhemdevice, dim_control, ondeviceaction, oninputdeviceaction, offdeviceaction, offinputdeviceaction, buildonly) {
+ $scope.buildDeviceUrls = function (fhemdevice, dim_control, buildonly) {
var preCmd = "/fhem?cmd=set%20" + fhemdevice.item.Name + "%20";
if(fhemdevice.item.PossibleSets.indexOf("dim") >= 0) {
if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0)) {
diff --git a/src/main/resources/public/views/fhemdevice.html b/src/main/resources/public/views/fhemdevice.html
index 2fe1906..6ccd8de 100644
--- a/src/main/resources/public/views/fhemdevice.html
+++ b/src/main/resources/public/views/fhemdevice.html
@@ -60,7 +60,7 @@
Name
+ ng-click="toggleSelectAll()">Device Name
| FHEM |
Capabilities |
Build Actions |
diff --git a/src/test/java/com/bwssystems/fhem/test/FHEMInstanceConstructor.java b/src/test/java/com/bwssystems/fhem/test/FHEMInstanceConstructor.java
index a5da668..d61756e 100644
--- a/src/test/java/com/bwssystems/fhem/test/FHEMInstanceConstructor.java
+++ b/src/test/java/com/bwssystems/fhem/test/FHEMInstanceConstructor.java
@@ -7,6 +7,7 @@ import com.bwssystems.HABridge.plugins.fhem.FHEMDevice;
import com.bwssystems.HABridge.plugins.fhem.FHEMInstance;
import com.bwssystems.HABridge.plugins.fhem.FHEMItem;
import com.bwssystems.HABridge.plugins.fhem.Result;
+import com.bwssystems.HABridge.plugins.http.HttpTestHandler;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;