diff --git a/pom.xml b/pom.xml
index 86ef569..455aa0b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.bwssystems.HABridge
ha-bridge
- 4.1.0beta3
+ 4.1.0beta4
jar
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzDevice.java b/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzDevice.java
index 45dcb8f..5525498 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzDevice.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzDevice.java
@@ -3,6 +3,7 @@ package com.bwssystems.HABridge.plugins.domoticz;
public class DomoticzDevice {
private String devicetype;
private String devicename;
+ private String idx;
private String domoticzaddress;
private String domoticzname;
public String getDevicetype() {
@@ -17,6 +18,12 @@ public class DomoticzDevice {
public void setDevicename(String devicename) {
this.devicename = devicename;
}
+ public String getIdx() {
+ return idx;
+ }
+ public void setIdx(String idx) {
+ this.idx = idx;
+ }
public String getDomoticzaddress() {
return domoticzaddress;
}
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzHandler.java b/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzHandler.java
index 5c6431e..379c7b7 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzHandler.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzHandler.java
@@ -57,7 +57,8 @@ public class DomoticzHandler {
DomoticzDevice aNewDomoticzDevice = new DomoticzDevice();
aNewDomoticzDevice.setDevicetype(theDevice.getType());
aNewDomoticzDevice.setDevicename(theDevice.getName());
- aNewDomoticzDevice.setDomoticzaddress(domoticzAddress.getIp());
+ aNewDomoticzDevice.setIdx(theDevice.getIdx());
+ aNewDomoticzDevice.setDomoticzaddress(domoticzAddress.getIp() + ":" + domoticzAddress.getPort());
aNewDomoticzDevice.setDomoticzname(domoticzAddress.getName());
deviceList.add(aNewDomoticzDevice);
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzHome.java b/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzHome.java
index 4af113c..bc538af 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzHome.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/domoticz/DomoticzHome.java
@@ -65,12 +65,7 @@ public class DomoticzHome implements Home {
Iterator devices = theSourceList.iterator();
while(devices.hasNext()) {
DomoticzDevice theDevice = devices.next();
- DomoticzDevice aNewDomoticzDevice = new DomoticzDevice();
- aNewDomoticzDevice.setDevicetype(theDevice.getDevicetype());
- aNewDomoticzDevice.setDevicename(theDevice.getDevicename());
- aNewDomoticzDevice.setDomoticzaddress(domoticzs.get(theKey).getDomoticzAddress().getIp());
- aNewDomoticzDevice.setDomoticzname(theKey);
- theDeviceList.add(aNewDomoticzDevice);
+ theDeviceList.add(theDevice);
}
anHttpHandler = new HTTPHandler();
return true;
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/hass/HassDevice.java b/src/main/java/com/bwssystems/HABridge/plugins/hass/HassDevice.java
index a69110e..27bdff5 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/hass/HassDevice.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/hass/HassDevice.java
@@ -4,6 +4,7 @@ public class HassDevice {
private State deviceState;
private String deviceName;
private String domain;
+ private Boolean secure;
private String hassaddress;
private String hassname;
public State getDeviceState() {
@@ -24,6 +25,12 @@ public class HassDevice {
public void setDomain(String domain) {
this.domain = domain;
}
+ public Boolean getSecure() {
+ return secure;
+ }
+ public void setSecure(Boolean secure) {
+ this.secure = secure;
+ }
public String getHassaddress() {
return hassaddress;
}
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/hass/HomeAssistant.java b/src/main/java/com/bwssystems/HABridge/plugins/hass/HomeAssistant.java
index 582a9d0..afc3549 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/hass/HomeAssistant.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/hass/HomeAssistant.java
@@ -36,7 +36,12 @@ public class HomeAssistant {
public Boolean callCommand(HassCommand aCommand) {
log.debug("calling HomeAssistant: " + aCommand.getHassName() + " - "
+ aCommand.getEntityId() + " - " + aCommand.getState() + " - " + aCommand.getBri());
- String aUrl = "http://" + hassAddress.getIp() + ":" + hassAddress.getPort() + "/api/services/" + aCommand.getEntityId().substring(0, aCommand.getEntityId().indexOf("."));
+ String aUrl = null;
+ if(hassAddress.getSecure())
+ aUrl = "https";
+ else
+ aUrl = "http";
+ aUrl = aUrl + "://" + hassAddress.getIp() + ":" + hassAddress.getPort() + "/api/services/" + aCommand.getEntityId().substring(0, aCommand.getEntityId().indexOf("."));
String aBody = "{\"entity_id\":\"" + aCommand.getEntityId() + "\"";
NameValue[] headers = null;
if(hassAddress.getPassword() != null && !hassAddress.getPassword().isEmpty()) {
@@ -75,7 +80,11 @@ public class HomeAssistant {
headers = new NameValue[1];
headers[0] = password;
}
- theUrl = "http://" + hassAddress.getIp() + ":" + hassAddress.getPort() + "/api/states";
+ if(hassAddress.getSecure())
+ theUrl = "https";
+ else
+ theUrl = "http";
+ theUrl = theUrl + "://" + hassAddress.getIp() + ":" + hassAddress.getPort() + "/api/states";
theData = anHttpHandler.doHttpRequest(theUrl, HttpGet.METHOD_NAME, "application/json", null, headers);
if(theData != null) {
log.debug("GET Hass States - data: " + theData);
diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js
index 29d420a..660d256 100644
--- a/src/main/resources/public/scripts/app.js
+++ b/src/main/resources/public/scripts/app.js
@@ -947,11 +947,11 @@ app.controller ('SystemController', function ($scope, $location, $http, $window,
}
}
};
- $scope.addHasstoSettings = function (newhassname, newhassip, newhassport, newhasspassword) {
+ $scope.addHasstoSettings = function (newhassname, newhassip, newhassport, newhasspassword, newhasssecure) {
if($scope.bridge.settings.hassaddress === undefined || $scope.bridge.settings.hassaddress === null) {
$scope.bridge.settings.hassaddress = { devices: [] };
}
- var newhass = {name: newhassname, ip: newhassip, port: newhassport, password: newhasspassword }
+ var newhass = {name: newhassname, ip: newhassip, port: newhassport, password: newhasspassword, secure: newhasssecure }
$scope.bridge.settings.hassaddress.devices.push(newhass);
$scope.newhassname = null;
$scope.newhassip = null;
@@ -2141,47 +2141,42 @@ app.controller('DomoticzController', function ($scope, $location, $http, bridgeS
};
$scope.buildDeviceUrls = function (domoticzdevice, dim_control) {
- var preOnCmd = "";
- var preDimCmd = "";
- var preOffCmd = "";
+ var preCmd = "";
+ var postOnCmd = "";
+ var postDimCmd = "";
+ var postOffCmd = "";
var nameCmd = "";
var aDeviceType;
var postCmd = "";
if(domoticzdevice.devicetype === "Scene") {
aDeviceType = "scene";
- preOnCmd = "/SceneService!SceneCmd=Set!SceneName=";
- preOffCmd = preOnCmd;
+ preCmd = "/json.htm?type=command¶m=switchscene&idx="
+ postOnCmd = "&switchcmd=On";
+ postOffCmd = "&switchcmd=Off";
}
else {
aDeviceType = "switch";
- preOnCmd = "/DeviceService!DeviceCmd=SetDevice!DeviceValue=On";
- preDimCmd = "/DeviceService!DeviceCmd=SetDevice!DeviceValue=Dim!DevicePercent=";
- preOffCmd = "/DeviceService!DeviceCmd=SetDevice!DeviceValue=Off";
- nameCmd = "!DeviceName=";
+ preCmd = "/json.htm?type=command¶m=switchlight&idx="
+ postOnCmd = "&switchcmd=On";
+ postDimCmd = "&switchcmd=Set%20Level&level=";
+ postOffCmd = "&switchcmd=Off";
}
if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) && aDeviceType === "switch")
dimpayload = "http://" + domoticzdevice.domoticzaddress
- + preDimCmd
- + dim_control
- + nameCmd
- + domoticzdevice.devicename.replaceAll(" ", "%20")
- + postCmd;
+ + preCmd
+ + domoticzdevice.idx
+ + postDimCmd
+ + dim_control;
else
- dimpayload = "http://" + domoticzdevice.domoticzaddress
- + preOnCmd
- + nameCmd
- + domoticzdevice.devicename.replaceAll(" ", "%20")
- + postCmd;
+ dimpayload = null;
onpayload = "http://" + domoticzdevice.domoticzaddress
- + preOnCmd
- + nameCmd
- + domoticzdevice.devicename.replaceAll(" ", "%20")
- + postCmd;
+ + preCmd
+ + domoticzdevice.idx
+ + postOnCmd;
offpayload = "http://" + domoticzdevice.domoticzaddress
- + preOffCmd
- + nameCmd
- + domoticzdevice.haldevicename.replaceAll(" ", "%20")
- + postCmd;
+ + preCmd
+ + domoticzdevice.idx
+ + postOffCmd;
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, domoticzdevice.devicename + "-" + domoticzdevice.domoticzname, domoticzdevice.devicename, domoticzdevice.domoticzname, aDeviceType, "domoticzDevice", null, null);
$scope.device = bridgeService.state.device;
bridgeService.editNewDevice($scope.device);
diff --git a/src/main/resources/public/views/system.html b/src/main/resources/public/views/system.html
index fe90841..e6b35ea 100644
--- a/src/main/resources/public/views/system.html
+++ b/src/main/resources/public/views/system.html
@@ -277,6 +277,7 @@
| IP |
Port |
Password (opt) |
+ Use SSL |
Manage |
@@ -286,6 +287,7 @@
{{hass.port}} |
******* |
|
+ {{hass.secure}} |
|
@@ -302,8 +304,11 @@
|
+ |
|
+ ng-click="addHasstoSettings(newhassname, newhassip, newhassport, newhasspassword, newhasssecure)">Add