mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
update for changes
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user