diff --git a/pom.xml b/pom.xml
index a6cba67..6e9db61 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.bwssystems.HABridge
ha-bridge
- 5.2.0RC8
+ 5.2.0RC9
jar
HA Bridge
diff --git a/src/main/java/com/bwssystems/HABridge/HABridge.java b/src/main/java/com/bwssystems/HABridge/HABridge.java
index 55b48cf..12bc450 100644
--- a/src/main/java/com/bwssystems/HABridge/HABridge.java
+++ b/src/main/java/com/bwssystems/HABridge/HABridge.java
@@ -49,14 +49,12 @@ public class HABridge {
// Singleton initialization
thePool = new HttpClientPool();
- log.info("HA Bridge (v" + theVersion.getVersion() + ") starting....");
-
bridgeSettings = new BridgeSettings();
// sparkjava config directive to set html static file location for Jetty
while(!bridgeSettings.getBridgeControl().isStop()) {
bridgeSettings.buildSettings();
bridgeSettings.getBridgeSecurity().removeTestUsers();
- log.info("HA Bridge initializing....");
+ log.info("HA Bridge (v" + theVersion.getVersion() + ") initializing....");
// sparkjava config directive to set ip address for the web server to listen on
ipAddress(bridgeSettings.getBridgeSettingsDescriptor().getWebaddress());
// sparkjava config directive to set port for the web server to listen on
@@ -91,7 +89,7 @@ public class HABridge {
bridgeSettings.getBridgeSettingsDescriptor().isUseupnpiface() + " on web server: " +
bridgeSettings.getBridgeSettingsDescriptor().getWebaddress() + ":" + bridgeSettings.getBridgeSettingsDescriptor().getServerPort());
// setup the class to handle the upnp response rest api
- theSettingResponder = new UpnpSettingsResource(bridgeSettings.getBridgeSettingsDescriptor());
+ theSettingResponder = new UpnpSettingsResource(bridgeSettings);
theSettingResponder.setupServer();
// start the upnp ssdp discovery listener
@@ -127,12 +125,12 @@ public class HABridge {
bridgeSettings.updateConfigFile();
try {
HttpClientPool.shutdown();
- thePool = null;
} catch (InterruptedException e) {
log.warn("Error shutting down http pool: " + e.getMessage());;
} catch (IOException e) {
log.warn("Error shutting down http pool: " + e.getMessage());;
}
+ thePool = null;
log.info("HA Bridge (v" + theVersion.getVersion() + ") exiting....");
System.exit(0);
}
diff --git a/src/main/java/com/bwssystems/HABridge/HomeManager.java b/src/main/java/com/bwssystems/HABridge/HomeManager.java
index 4339b5e..30d7b17 100644
--- a/src/main/java/com/bwssystems/HABridge/HomeManager.java
+++ b/src/main/java/com/bwssystems/HABridge/HomeManager.java
@@ -42,6 +42,14 @@ public class HomeManager {
// factory method
public void buildHomes(BridgeSettings bridgeSettings, UDPDatagramSender aUdpDatagramSender) {
Home aHome = null;
+ //setup the http handler Home - This must be the first home created for devMode
+ aHome = new HTTPHome(bridgeSettings);
+ homeList.put(DeviceMapTypes.HTTP_DEVICE[DeviceMapTypes.typeIndex], aHome);
+ homeList.put(DeviceMapTypes.CUSTOM_DEVICE[DeviceMapTypes.typeIndex], aHome);
+ homeList.put(DeviceMapTypes.VERA_DEVICE[DeviceMapTypes.typeIndex], aHome);
+ homeList.put(DeviceMapTypes.VERA_SCENE[DeviceMapTypes.typeIndex], aHome);
+ homeList.put(DeviceMapTypes.FIBARO_DEVICE[DeviceMapTypes.typeIndex], aHome);
+ homeList.put(DeviceMapTypes.FIBARO_SCENE[DeviceMapTypes.typeIndex], aHome);
//setup the harmony connection if available
aHome = new HarmonyHome(bridgeSettings);
resourceList.put(DeviceMapTypes.HARMONY_ACTIVITY[DeviceMapTypes.typeIndex], aHome);
@@ -80,14 +88,6 @@ public class HomeManager {
aHome = new CommandHome(bridgeSettings);
homeList.put(DeviceMapTypes.EXEC_DEVICE_COMPAT[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.CMD_DEVICE[DeviceMapTypes.typeIndex], aHome);
- //setup the http handler Home
- aHome = new HTTPHome(bridgeSettings);
- homeList.put(DeviceMapTypes.HTTP_DEVICE[DeviceMapTypes.typeIndex], aHome);
- homeList.put(DeviceMapTypes.CUSTOM_DEVICE[DeviceMapTypes.typeIndex], aHome);
- homeList.put(DeviceMapTypes.VERA_DEVICE[DeviceMapTypes.typeIndex], aHome);
- homeList.put(DeviceMapTypes.VERA_SCENE[DeviceMapTypes.typeIndex], aHome);
- homeList.put(DeviceMapTypes.FIBARO_DEVICE[DeviceMapTypes.typeIndex], aHome);
- homeList.put(DeviceMapTypes.FIBARO_SCENE[DeviceMapTypes.typeIndex], aHome);
//setup the tcp handler Home
aHome = new TCPHome(bridgeSettings);
homeList.put(DeviceMapTypes.TCP_DEVICE[DeviceMapTypes.typeIndex], aHome);
diff --git a/src/main/java/com/bwssystems/HABridge/hue/BrightnessDecode.java b/src/main/java/com/bwssystems/HABridge/hue/BrightnessDecode.java
index f6247c8..bf58183 100644
--- a/src/main/java/com/bwssystems/HABridge/hue/BrightnessDecode.java
+++ b/src/main/java/com/bwssystems/HABridge/hue/BrightnessDecode.java
@@ -111,11 +111,7 @@ public class BrightnessDecode {
Integer endResult = calculateMath(variables, mathDescriptor);
if(endResult != null) {
- if (isHex) {
- replaceValue = convertToHex(endResult);
- } else {
- replaceValue = endResult.toString();
- }
+ replaceValue = convertToHex(endResult);
replaceTarget = INTENSITY_MATH + mathDescriptor + INTENSITY_MATH_CLOSE_HEX;
notDone = 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
index 10bb547..10d7ceb 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/http/HttpTestHandler.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/http/HttpTestHandler.java
@@ -45,14 +45,21 @@ public class HttpTestHandler extends HTTPHandler {
log.info("header index " + i + " name: <<<" + headers[i].getName() + ">>>, value: <<<" + headers[i].getValue() + ">>>");
String responseData = null;
for(NameValue aTest:theData) {
- if(url.contains(aTest.getName()))
- responseData = aTest.getValue();
- else if(aTest.getName() == null || aTest.getName().isEmpty())
+ if(aTest.getName() == null)
responseData = aTest.getValue();
+ else {
+ if(url.contains(aTest.getName()))
+ responseData = aTest.getValue();
+ else if(aTest.getName() == null || aTest.getName().isEmpty())
+ responseData = aTest.getValue();
+ }
if(responseData != null)
break;
}
+
+ if(responseData == null)
+ responseData = "No data was set for HttpTestHandler for your request url.";
return responseData;
}
}
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/openhab/OpenHABInstance.java b/src/main/java/com/bwssystems/HABridge/plugins/openhab/OpenHABInstance.java
index 1d6e7a5..4a6aa4e 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/openhab/OpenHABInstance.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/openhab/OpenHABInstance.java
@@ -66,22 +66,26 @@ public class OpenHABInstance {
theData = httpClient.doHttpRequest(theUrl, HttpGet.METHOD_NAME, "application/json", null, headers);
if(theData != null) {
log.debug("GET OpenHAB States - data: " + theData);
- theOpenhabStates = new Gson().fromJson(theData, OpenHABItem[].class);
- if(theOpenhabStates == null) {
- log.warn("Cannot get any devices for OpenHAB " + theOpenHAB.getName() + " as response is not parsable.");
- }
- else {
- deviceList = new ArrayList();
-
- for (int i = 0; i < theOpenhabStates.length; i++) {
- OpenHABDevice aNewOpenHABDeviceDevice = new OpenHABDevice();
- aNewOpenHABDeviceDevice.setItem(theOpenhabStates[i]);
- aNewOpenHABDeviceDevice.setAddress(theOpenHAB.getIp() + ":" + theOpenHAB.getPort());
- aNewOpenHABDeviceDevice.setName(theOpenHAB.getName());
- deviceList.add(aNewOpenHABDeviceDevice);
-
- }
- }
+ try {
+ theOpenhabStates = new Gson().fromJson(theData, OpenHABItem[].class);
+ if(theOpenhabStates == null) {
+ log.warn("Cannot get any devices for OpenHAB " + theOpenHAB.getName() + " as response is not parsable.");
+ }
+ else {
+ deviceList = new ArrayList();
+
+ for (int i = 0; i < theOpenhabStates.length; i++) {
+ OpenHABDevice aNewOpenHABDeviceDevice = new OpenHABDevice();
+ aNewOpenHABDeviceDevice.setItem(theOpenhabStates[i]);
+ aNewOpenHABDeviceDevice.setAddress(theOpenHAB.getIp() + ":" + theOpenHAB.getPort());
+ aNewOpenHABDeviceDevice.setName(theOpenHAB.getName());
+ deviceList.add(aNewOpenHABDeviceDevice);
+
+ }
+ }
+ } catch (Exception e) {
+ log.warn("Cannot get an devices for OpenHAB " + theOpenHAB.getName() + " Gson Parse Error.");
+ }
}
else
log.warn("Cannot get an devices for OpenHAB " + theOpenHAB.getName() + " http call failed.");
diff --git a/src/main/java/com/bwssystems/HABridge/upnp/UpnpSettingsResource.java b/src/main/java/com/bwssystems/HABridge/upnp/UpnpSettingsResource.java
index 19723d0..fa98b07 100644
--- a/src/main/java/com/bwssystems/HABridge/upnp/UpnpSettingsResource.java
+++ b/src/main/java/com/bwssystems/HABridge/upnp/UpnpSettingsResource.java
@@ -3,6 +3,7 @@ package com.bwssystems.HABridge.upnp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.bwssystems.HABridge.BridgeSettings;
import com.bwssystems.HABridge.BridgeSettingsDescriptor;
import com.bwssystems.HABridge.api.hue.HueConstants;
import com.bwssystems.HABridge.api.hue.HuePublicConfig;
@@ -16,6 +17,7 @@ public class UpnpSettingsResource {
private Logger log = LoggerFactory.getLogger(UpnpSettingsResource.class);
private BridgeSettingsDescriptor theSettings;
+ private BridgeSettings bridgeSettings;
private String hueTemplate = "\n"
+ "\n"
@@ -55,15 +57,22 @@ public class UpnpSettingsResource {
+ "\n"
+ "\n";
- public UpnpSettingsResource(BridgeSettingsDescriptor theBridgeSettings) {
+ public UpnpSettingsResource(BridgeSettings theBridgeSettings) {
super();
- this.theSettings = theBridgeSettings;
+ this.bridgeSettings = theBridgeSettings;
+ this.theSettings = theBridgeSettings.getBridgeSettingsDescriptor();
}
public void setupServer() {
log.info("Description xml service started....");
// http://ip_adress:port/description.xml which returns the xml configuration for the hue emulator
get("/description.xml", "application/xml; charset=utf-8", (request, response) -> {
+ if(bridgeSettings.getBridgeControl().isReinit() || bridgeSettings.getBridgeControl().isStop()) {
+ log.info("Get description.xml called while in re-init or stop state");
+ response.status(503);
+ return null;
+ }
+
String portNumber = Integer.toString(request.port());
String filledTemplate = null;
String bridgeIdMac = HuePublicConfig.createConfig("temp", theSettings.getUpnpConfigAddress(), HueConstants.HUB_VERSION, theSettings.getHubmac()).getSNUUIDFromMac();
diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js
index 9c71386..4a1986e 100644
--- a/src/main/resources/public/scripts/app.js
+++ b/src/main/resources/public/scripts/app.js
@@ -3049,6 +3049,8 @@ app.controller('MQTTController', function ($scope, $location, bridgeService, ngD
bridgeService.viewMQTTDevices();
$scope.imgButtonsUrl = "glyphicon glyphicon-plus";
$scope.buttonsVisible = false;
+ $scope.mqttretain = false;
+ $scope.mqttqos = 1;
$scope.clearDevice = function () {
bridgeService.clearDevice();
@@ -3056,6 +3058,10 @@ app.controller('MQTTController', function ($scope, $location, bridgeService, ngD
};
$scope.buildMQTTPublish = function (mqttbroker, mqtttopic, mqttmessage, mqttqos, mqttretain) {
+ if(mqttretain === 'undefined')
+ mqttretain = false;
+ if(mqttqos === 'undefined')
+ mqttqos = 1;
onpayload = "{\"clientId\":\"" + mqttbroker.clientId + "\",\"topic\":\"" + mqtttopic + "\",\"message\":\"" + mqttmessage + "\",\"qos\":\"" + mqttqos + "\",\"retain\":\"" + mqttretain + "\"}";
offpayload = "{\"clientId\":\"" + mqttbroker.clientId + "\",\"topic\":\"" + mqtttopic + "\",\"message\":\"" + mqttmessage + "\",\"qos\":\"" + mqttqos + "\",\"retain\":\"" + mqttretain + "\"}";
@@ -3926,16 +3932,23 @@ app.controller('FhemController', function ($scope, $location, bridgeService, ngD
$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(fhemdevice.item.PossibleSets.toLowerCase().indexOf("dim") >= 0) {
if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0)) {
dimpayload = "{\"url\":\"http://" + fhemdevice.address + preCmd + "\",\"command\":\"dim%20" + dim_control + "\"}";
}
else
dimpayload = "{\"url\":\"http://" + fhemdevice.address + preCmd + "\",\"command\":\"dim%20${intensity.percent}\"}";
}
+ else if(fhemdevice.item.PossibleSets.toLowerCase().indexOf("pct") >= 0) {
+ if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0)) {
+ dimpayload = "{\"url\":\"http://" + fhemdevice.address + preCmd + "\",\"command\":\"pct%20" + dim_control + "\"}";
+ }
+ else
+ dimpayload = "{\"url\":\"http://" + fhemdevice.address + preCmd + "\",\"command\":\"pct%20${intensity.percent}\"}";
+ }
else
dimpayload = null;
- if(fhemdevice.item.PossibleSets.indexOf("RGB") >= 0) {
+ if(fhemdevice.item.PossibleSets.toLowerCase().indexOf("rgb") >= 0) {
colorpayload = "{\"url\":\"http://" + fhemdevice.address + preCmd + "\",\"command\":\"RGB%20${color.rgbx}\"}";
}
else
diff --git a/src/main/resources/public/views/broadlinkdevice.html b/src/main/resources/public/views/broadlinkdevice.html
index 120db0e..1072e67 100644
--- a/src/main/resources/public/views/broadlinkdevice.html
+++ b/src/main/resources/public/views/broadlinkdevice.html
@@ -17,7 +17,7 @@
Somfy Devices
LIFX Devices
HomeWizard Devices
- broadlink Devices
+ OpenHAB Devices
FHEM Devices
Broadlink Devices
Add/Edit
diff --git a/src/main/resources/public/views/mqttpublish.html b/src/main/resources/public/views/mqttpublish.html
index 2c630d9..5ee77ad 100644
--- a/src/main/resources/public/views/mqttpublish.html
+++ b/src/main/resources/public/views/mqttpublish.html
@@ -71,8 +71,9 @@
ng-model="mqttqos" placeholder="1"/>
|
-
+ {{mqttretain}} |
|