update for changes

This commit is contained in:
bsamuels
2018-01-16 16:13:24 -06:00
parent 27dd8475e9
commit 18c47ee5e4
7 changed files with 37 additions and 7 deletions

View File

@@ -5,7 +5,7 @@
<groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId>
<version>5.2.0RC4</version>
<version>5.2.0RC5</version>
<packaging>jar</packaging>
<name>HA Bridge</name>

View File

@@ -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<String, FHEMInstance> 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<String,FHEMInstance>();
httpClient = HTTPHome.getHandler();
if(isDevMode) {
httpClient = new HttpTestHandler();
((HttpTestHandler)httpClient).setTheData(FHEMInstanceConstructor.TestData);
}
Iterator<NamedIP> theList = bridgeSettings.getBridgeSettingsDescriptor().getFhemaddress().getDevices().iterator();
while(theList.hasNext() && validFhem) {
NamedIP aFhem = theList.next();

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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)) {

View File

@@ -60,7 +60,7 @@
<span><input type="checkbox" name="selectAll"
value="{{selectAll}}"
ng-checked="selectAll"
ng-click="toggleSelectAll()"> Name</span></th>
ng-click="toggleSelectAll()">Device Name</span></th>
<th sortable-header col="fhemname">FHEM</th>
<th sortable-header col="type">Capabilities</th>
<th>Build Actions</th>

View File

@@ -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;