Finished implementation of HAL calls to the API. Testing next.

This commit is contained in:
Admin
2016-05-26 16:06:48 -05:00
parent 6b4693eaaf
commit d7e29e2ee5
11 changed files with 201 additions and 117 deletions

View File

@@ -5,7 +5,7 @@
<groupId>com.bwssystems.HABridge</groupId> <groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId> <artifactId>ha-bridge</artifactId>
<version>2.0.7-hal-c</version> <version>2.0.7-hal-d</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>HA Bridge</name> <name>HA Bridge</name>
@@ -89,7 +89,7 @@
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.2.4</version> <version>2.6.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>

View File

@@ -1,8 +1,10 @@
package com.bwssystems.hal; package com.bwssystems.hal;
import java.util.List; import java.util.List;
import com.google.gson.annotations.SerializedName;
public class DeviceElements { public class DeviceElements {
@SerializedName(value="DeviceElements", alternate={"SceneElements", "GroupElements", "HVACElements", "MacroElements", "IrElements", "IrButtons"})
private List<DeviceName> DeviceElements; private List<DeviceName> DeviceElements;
public List<DeviceName> getDeviceElements() { public List<DeviceName> getDeviceElements() {

View File

@@ -1,6 +1,9 @@
package com.bwssystems.hal; package com.bwssystems.hal;
import com.google.gson.annotations.SerializedName;
public class DeviceName { public class DeviceName {
@SerializedName(value="DeviceName", alternate={"SceneName", "GroupName", "HVACName", "MacroName", "IrName", "IrButton"})
private String DeviceName; private String DeviceName;
public String getDeviceName() { public String getDeviceName() {

View File

@@ -1,15 +0,0 @@
package com.bwssystems.hal;
import java.util.List;
public class HVACElements {
private List<HVACName> HVACElements;
public List<HVACName> getHVACElements() {
return HVACElements;
}
public void setHVACElements(List<HVACName> hVACElements) {
HVACElements = hVACElements;
}
}

View File

@@ -1,13 +0,0 @@
package com.bwssystems.hal;
public class HVACName {
private String HVACName;
public String getHVACName() {
return HVACName;
}
public void setHVACName(String hVACName) {
HVACName = hVACName;
}
}

View File

@@ -5,6 +5,7 @@ public class HalDevice {
private String haldevicename; private String haldevicename;
private String haladdress; private String haladdress;
private String halname; private String halname;
private DeviceElements buttons;
public String getHaldevicetype() { public String getHaldevicetype() {
return haldevicetype; return haldevicetype;
} }
@@ -29,4 +30,10 @@ public class HalDevice {
public void setHalname(String halname) { public void setHalname(String halname) {
this.halname = halname; this.halname = halname;
} }
public DeviceElements getButtons() {
return buttons;
}
public void setButtons(DeviceElements buttons) {
this.buttons = buttons;
}
} }

View File

@@ -69,7 +69,27 @@ public class HalHome {
if(theResponse != null) if(theResponse != null)
addHalDevices(deviceList, theResponse, key); addHalDevices(deviceList, theResponse, key);
else else
log.warn("Cannot get HVAC for Hal with name: " + key); log.warn("Cannot get Homes for Hal with name: " + key);
theResponse = hals.get(key).getGroups();
if(theResponse != null)
addHalDevices(deviceList, theResponse, key);
else
log.warn("Cannot get Groups for Hal with name: " + key);
theResponse = hals.get(key).getMacros();
if(theResponse != null)
addHalDevices(deviceList, theResponse, key);
else
log.warn("Cannot get Macros for Hal with name: " + key);
theResponse = hals.get(key).getScenes();
if(theResponse != null)
addHalDevices(deviceList, theResponse, key);
else
log.warn("Cannot get Scenes for Hal with name: " + key);
theResponse = hals.get(key).getButtons();
if(theResponse != null)
addHalDevices(deviceList, theResponse, key);
else
log.warn("Cannot get Buttons for Hal with name: " + key);
} }
return deviceList; return deviceList;
} }
@@ -81,6 +101,7 @@ public class HalHome {
HalDevice aNewHalDevice = new HalDevice(); HalDevice aNewHalDevice = new HalDevice();
aNewHalDevice.setHaldevicetype(theDevice.getHaldevicetype()); aNewHalDevice.setHaldevicetype(theDevice.getHaldevicetype());
aNewHalDevice.setHaldevicename(theDevice.getHaldevicename()); aNewHalDevice.setHaldevicename(theDevice.getHaldevicename());
aNewHalDevice.setButtons(theDevice.getButtons());
aNewHalDevice.setHaladdress(hals.get(theKey).getHalAddress().getIp()); aNewHalDevice.setHaladdress(hals.get(theKey).getHalAddress().getIp());
aNewHalDevice.setHalname(theKey); aNewHalDevice.setHalname(theKey);
theDeviceList.add(aNewHalDevice); theDeviceList.add(aNewHalDevice);

View File

@@ -15,12 +15,18 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.bwssystems.HABridge.NamedIP; import com.bwssystems.HABridge.NamedIP;
import com.bwssystems.util.TextStringFormatter;
import com.google.gson.Gson; import com.google.gson.Gson;
public class HalInfo { public class HalInfo {
private static final Logger log = LoggerFactory.getLogger(HalInfo.class); private static final Logger log = LoggerFactory.getLogger(HalInfo.class);
private static final String DEVICE_REQUEST = "/DeviceData!DeviceCmd=GetNames!DeviceType="; private static final String DEVICE_REQUEST = "/DeviceData!DeviceCmd=GetNames!DeviceType=";
private static final String HVAC_REQUEST = "/HVACData!HVACCmd=GetNames"; private static final String HVAC_REQUEST = "/HVACData!HVACCmd=GetNames";
private static final String GROUP_REQUEST = "/GroupData!GroupCmd=GetNames";
private static final String MACRO_REQUEST = "/MacroData!MacroCmd=GetNames";
private static final String SCENE_REQUEST = "/SceneData!SceneCmd=GetNames";
private static final String IRDATA_REQUEST = "/IrData!IRCmd=GetNames";
private static final String IRBUTTON_REQUEST = "/IrData!IRCmd=GetButtons!IrDevice=";
private static final String TOKEN_REQUEST = "?Token="; private static final String TOKEN_REQUEST = "?Token=";
private static final String LIGHT_REQUEST = "Light"; private static final String LIGHT_REQUEST = "Light";
private static final String APPL_REQUEST = "Appl"; private static final String APPL_REQUEST = "Appl";
@@ -28,7 +34,11 @@ public class HalInfo {
private static final String THEATRE_REQUEST = "Theatre"; private static final String THEATRE_REQUEST = "Theatre";
private static final String CUSTOM_REQUEST = "Custom"; private static final String CUSTOM_REQUEST = "Custom";
private static final String HVAC_TYPE = "HVAC"; private static final String HVAC_TYPE = "HVAC";
private static final String HOME_TYPE = "HOME"; private static final String HOME_TYPE = "Home";
private static final String GROUP_TYPE = "Group";
private static final String MACRO_TYPE = "Macro";
private static final String SCENE_TYPE = "Scene";
private static final String IRDATA_TYPE = "IrData";
private HttpClient httpClient; private HttpClient httpClient;
private NamedIP halAddress; private NamedIP halAddress;
private String theToken; private String theToken;
@@ -57,7 +67,25 @@ public class HalInfo {
} }
public List<HalDevice> getHVAC() { public List<HalDevice> getHVAC() {
return getHalHVAC(HVAC_REQUEST + TOKEN_REQUEST, HVAC_TYPE); return getHalDevices(HVAC_REQUEST + TOKEN_REQUEST, HVAC_TYPE);
}
public List<HalDevice> getGroups() {
return getHalDevices(GROUP_REQUEST + TOKEN_REQUEST, GROUP_TYPE);
}
public List<HalDevice> getMacros() {
return getHalDevices(MACRO_REQUEST + TOKEN_REQUEST, MACRO_TYPE);
}
public List<HalDevice> getScenes() {
return getHalDevices(SCENE_REQUEST + TOKEN_REQUEST, SCENE_TYPE);
}
public List<HalDevice> getButtons() {
List<HalDevice> irDataDevices = getHalDevices(IRDATA_REQUEST + TOKEN_REQUEST, IRDATA_TYPE);
return getDeviceButtons(irDataDevices);
} }
public List<HalDevice> getHome(String theDeviceName) { public List<HalDevice> getHome(String theDeviceName) {
@@ -79,7 +107,7 @@ public class HalInfo {
theUrl = "http://" + halAddress.getIp() + apiType + theToken; theUrl = "http://" + halAddress.getIp() + apiType + theToken;
theData = doHttpGETRequest(theUrl); theData = doHttpGETRequest(theUrl);
if(theData != null) { if(theData != null) {
log.debug("GET HalApiResponse - data: " + theData); log.debug("GET " + deviceType + " HalApiResponse - data: " + theData);
theHalApiResponse = new Gson().fromJson(theData, DeviceElements.class); theHalApiResponse = new Gson().fromJson(theData, DeviceElements.class);
if(theHalApiResponse.getDeviceElements() == null) { if(theHalApiResponse.getDeviceElements() == null) {
StatusDescription theStatus = new Gson().fromJson(theData, StatusDescription.class); StatusDescription theStatus = new Gson().fromJson(theData, StatusDescription.class);
@@ -109,42 +137,41 @@ public class HalInfo {
return deviceList; return deviceList;
} }
private List<HalDevice> getHalHVAC(String apiType, String deviceType) { private List<HalDevice> getDeviceButtons(List<HalDevice> theIrDevices) {
HVACElements theHalApiResponse = null; DeviceElements theHalApiResponse = null;
List<HalDevice> deviceList = null; List<HalDevice> deviceList = null;
String theUrl = null; String theUrl = null;
String theData; String theData;
theUrl = "http://" + halAddress.getIp() + apiType + theToken; Iterator<HalDevice> theHalDevices = theIrDevices.iterator();
deviceList = new ArrayList<HalDevice>();
while (theHalDevices.hasNext()) {
HalDevice theHalDevice = theHalDevices.next();
theUrl = "http://" + halAddress.getIp() + IRBUTTON_REQUEST + TextStringFormatter.forQuerySpaceUrl(theHalDevice.getHaldevicename()) + TOKEN_REQUEST + theToken;
theData = doHttpGETRequest(theUrl); theData = doHttpGETRequest(theUrl);
if(theData != null) { if (theData != null) {
log.debug("GET HalApiResponse - data: " + theData); log.debug("GET IrData for IR Device " + theHalDevice.getHaldevicename() + " HalApiResponse - data: " + theData);
theHalApiResponse = new Gson().fromJson(theData, HVACElements.class); theHalApiResponse = new Gson().fromJson(theData, DeviceElements.class);
if(theHalApiResponse.getHVACElements() == null) { if (theHalApiResponse.getDeviceElements() == null) {
StatusDescription theStatus = new Gson().fromJson(theData, StatusDescription.class); StatusDescription theStatus = new Gson().fromJson(theData, StatusDescription.class);
if(theStatus.getStatus() == null) { if (theStatus.getStatus() == null) {
log.warn("Cannot get an devices for type " + deviceType + " for hal " + halAddress.getName() + " as response is not parsable."); log.warn("Cannot get buttons for IR Device " + theHalDevice.getHaldevicename() + " for hal "
} + halAddress.getName() + " as response is not parsable.");
else { } else {
log.warn("Cannot get an devices for type " + deviceType + " for hal " + halAddress.getName() + ". Status: " + theStatus.getStatus() + ", with description: " + theStatus.getDescription()); log.warn("Cannot get buttons for IR Device " + theHalDevice.getHaldevicename() + " for hal "
+ halAddress.getName() + ". Status: " + theStatus.getStatus() + ", with description: "
+ theStatus.getDescription());
} }
return deviceList; return deviceList;
} }
deviceList = new ArrayList<HalDevice>(); theHalDevice.setButtons(theHalApiResponse);
deviceList.add(theHalDevice);
Iterator<HVACName> theDeviceNames = theHalApiResponse.getHVACElements().iterator();
while(theDeviceNames.hasNext()) {
HVACName theDevice = theDeviceNames.next();
HalDevice aNewHalDevice = new HalDevice();
aNewHalDevice.setHaldevicetype(deviceType);
aNewHalDevice.setHaldevicename(theDevice.getHVACName());
deviceList.add(aNewHalDevice);
} else {
log.warn("Get Hal buttons for IR Device " + theHalDevice.getHaldevicename() + " for "
+ halAddress.getName() + " - returned null, no data.");
} }
} }
else {
log.warn("Get Hal device types " + deviceType + " for " + halAddress.getName() + " - returned null, no data.");
}
return deviceList; return deviceList;
} }

View File

@@ -1396,37 +1396,83 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
$scope.buildDeviceUrls = function (haldevice, dim_control) { $scope.buildDeviceUrls = function (haldevice, dim_control) {
bridgeService.clearDevice(); bridgeService.clearDevice();
$scope.device = $scope.bridge.device; $scope.device = $scope.bridge.device;
var preOnCmd = "";
var preDimCmd = "";
var preOffCmd = "";
var nameCmd = ""
var postCmd = "?Token=" + $scope.bridge.settings.haltoken;
if(haldevice.haldevicetype == "Group") {
$scope.device.deviceType = "group";
preOnCmd = "/GroupService!GroupCmd=On";
preOffCmd = "/GroupService!GroupCmd=Off";
nameCmd = "!GroupName=";
}
else if(haldevice.haldevicetype == "Macro") {
$scope.device.deviceType = "macro";
preOnCmd = "/MacroService!MacroCmd=Set!MacroName=";
preOffCmd = preOnCmd;
}
else if(haldevice.haldevicetype == "Scene") {
$scope.device.deviceType = "scene";
preOnCmd = "/SceneService!SceneCmd=Set!SceneName=";
preOffCmd = preOnCmd;
}
else {
$scope.device.deviceType = "switch"; $scope.device.deviceType = "switch";
preOnCmd = "/DeviceService!DeviceCmd=SetDevice!DeviceValue=On";
preDimCmd = "/DeviceService!DeviceCmd=SetDevice!DeviceValue=Dim!DevicePercent=";
preOffCmd = "/DeviceService!DeviceCmd=SetDevice!DeviceValue=Off";
nameCmd = "!DeviceName=";
}
$scope.device.name = haldevice.haldevicename; $scope.device.name = haldevice.haldevicename;
$scope.device.targetDevice = haldevice.halname; $scope.device.targetDevice = haldevice.halname;
$scope.device.mapType = "halDevice"; $scope.device.mapType = "halDevice";
$scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname; $scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname;
if(dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) && $scope.device.deviceType == "switch")
$scope.device.dimUrl = "http://" + haldevice.haladdress $scope.device.dimUrl = "http://" + haldevice.haladdress
+ "/DeviceService!DeviceName=" + preDimCmd
+ haldevice.haldevicename.replaceAll(" ", "%20")
+ "!DeviceCmd=SetDevice!DeviceValue=Dim!DevicePercent="
+ dim_control + dim_control
+ "?Token=" + nameCmd
+ $scope.bridge.settings.haltoken; + haldevice.haldevicename.replaceAll(" ", "%20")
+ postCmd;
else else
$scope.device.dimUrl = "http://" + haldevice.haladdress $scope.device.dimUrl = "http://" + haldevice.haladdress
+ "/DeviceService!DeviceName=" + preOnCmd
+ nameCmd
+ haldevice.haldevicename.replaceAll(" ", "%20") + haldevice.haldevicename.replaceAll(" ", "%20")
+ "!DeviceCmd=SetDevice!DeviceValue=On?Token=" + postCmd;
+ $scope.bridge.settings.haltoken;
$scope.device.onUrl = "http://" + haldevice.haladdress $scope.device.onUrl = "http://" + haldevice.haladdress
+ "/DeviceService!DeviceName=" + preOnCmd
+ nameCmd
+ haldevice.haldevicename.replaceAll(" ", "%20") + haldevice.haldevicename.replaceAll(" ", "%20")
+ "!DeviceCmd=SetDevice!DeviceValue=On?Token=" + postCmd;
+ $scope.bridge.settings.haltoken;
$scope.device.offUrl = "http://" + haldevice.haladdress $scope.device.offUrl = "http://" + haldevice.haladdress
+ "/DeviceService!DeviceName=" + preOffCmd
+ nameCmd
+ haldevice.haldevicename.replaceAll(" ", "%20") + haldevice.haldevicename.replaceAll(" ", "%20")
+ "!DeviceCmd=SetDevice!DeviceValue=Off?Token=" + postCmd;
+ $scope.bridge.settings.haltoken; };
$scope.buildButtonUrls = function (haldevice, onbutton, offbutton) {
var currentOn = $scope.device.onUrl;
var currentOff = $scope.device.offUrl;
var actionOn = angular.fromJson(onbutton);
var actionOff = angular.fromJson(offbutton);
if( $scope.device.mapType == "halButton") {
$scope.device.mapId = $scope.device.mapId + "-" + actionOn.DeviceName;
$scope.device.onUrl = currentOn.substr(0, currentOn.indexOf("]")) + ",{\"item\":\"http://" + haldevice.haladdress + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOn.DeviceName.replaceAll(" ", "%20") + "?Token=" + $scope.bridge.settings.haltoken +"\"}]";
$scope.device.offUrl = currentOff.substr(0, currentOff.indexOf("]")) + ",{\"item\":\"http://" + haldevice.haladdress + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOff.DeviceName.replaceAll(" ", "%20") + "?Token=" + $scope.bridge.settings.haltoken + "\"}]";
}
else if ($scope.device.mapType == null || $scope.device.mapType == "") {
bridgeService.clearDevice();
$scope.device.deviceType = "button";
$scope.device.targetDevice = haldevice.halname;
$scope.device.name = haldevice.haldevicename;
$scope.device.mapType = "halButton";
$scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname + "-" + actionOn.DeviceName;
$scope.device.onUrl = "[{\"item\":\"http://" + haldevice.haladdress + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOn.DeviceName.replaceAll(" ", "%20") + "?Token=" + $scope.bridge.settings.haltoken + "\"}]";
$scope.device.offUrl = "[{\"item\":\"http://" + haldevice.haladdress + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOff.DeviceName.replaceAll(" ", "%20") + "?Token=" + $scope.bridge.settings.haltoken + "\"}]";
}
}; };
$scope.buildHALHomeUrls = function (haldevice) { $scope.buildHALHomeUrls = function (haldevice) {
@@ -1445,7 +1491,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
$scope.device.deviceType = "thermo"; $scope.device.deviceType = "thermo";
$scope.device.name = haldevice.haldevicename + " Heat"; $scope.device.name = haldevice.haldevicename + " Heat";
$scope.device.targetDevice = haldevice.halname; $scope.device.targetDevice = haldevice.halname;
$scope.device.mapType = "HALThermoSet"; $scope.device.mapType = "halThermoSet";
$scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname + "-SetHeat"; $scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname + "-SetHeat";
$scope.device.onUrl = "http://" + haldevice.haladdress $scope.device.onUrl = "http://" + haldevice.haladdress
+ "/HVACService!HVACCmd=Set!HVACName=" + "/HVACService!HVACCmd=Set!HVACName="
@@ -1468,7 +1514,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
$scope.device.deviceType = "thermo"; $scope.device.deviceType = "thermo";
$scope.device.name = haldevice.haldevicename + " Cool"; $scope.device.name = haldevice.haldevicename + " Cool";
$scope.device.targetDevice = haldevice.halname; $scope.device.targetDevice = haldevice.halname;
$scope.device.mapType = "HALThermoSet"; $scope.device.mapType = "halThermoSet";
$scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname + "-SetCool"; $scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname + "-SetCool";
$scope.device.onUrl = "http://" + haldevice.haladdress $scope.device.onUrl = "http://" + haldevice.haladdress
+ "/HVACService!HVACCmd=Set!HVACName=" + "/HVACService!HVACCmd=Set!HVACName="
@@ -1491,7 +1537,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
$scope.device.deviceType = "thermo"; $scope.device.deviceType = "thermo";
$scope.device.name = haldevice.haldevicename + " Auto"; $scope.device.name = haldevice.haldevicename + " Auto";
$scope.device.targetDevice = haldevice.halname; $scope.device.targetDevice = haldevice.halname;
$scope.device.mapType = "HALThermoSet"; $scope.device.mapType = "halThermoSet";
$scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname + "-SetAuto"; $scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname + "-SetAuto";
$scope.device.onUrl = "http://" + haldevice.haladdress $scope.device.onUrl = "http://" + haldevice.haladdress
+ "/HVACService!HVACCmd=Set!HVACName=" + "/HVACService!HVACCmd=Set!HVACName="
@@ -1509,7 +1555,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
$scope.device.deviceType = "thermo"; $scope.device.deviceType = "thermo";
$scope.device.name = haldevice.haldevicename + " Thermostat"; $scope.device.name = haldevice.haldevicename + " Thermostat";
$scope.device.targetDevice = haldevice.halname; $scope.device.targetDevice = haldevice.halname;
$scope.device.mapType = "HALThermoSet"; $scope.device.mapType = "halThermoSet";
$scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname + "-TurnOff"; $scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname + "-TurnOff";
$scope.device.onUrl = "http://" + haldevice.haladdress $scope.device.onUrl = "http://" + haldevice.haladdress
+ "/HVACService!HVACCmd=Set!HVACName=" + "/HVACService!HVACCmd=Set!HVACName="
@@ -1527,7 +1573,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
$scope.device.deviceType = "thermo"; $scope.device.deviceType = "thermo";
$scope.device.name = haldevice.haldevicename + " Fan"; $scope.device.name = haldevice.haldevicename + " Fan";
$scope.device.targetDevice = haldevice.halname; $scope.device.targetDevice = haldevice.halname;
$scope.device.mapType = "HALThermoSet"; $scope.device.mapType = "halThermoSet";
$scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname + "-SetFan"; $scope.device.mapId = haldevice.haldevicename + "-" + haldevice.halname + "-SetFan";
$scope.device.onUrl = "http://" + haldevice.haladdress $scope.device.onUrl = "http://" + haldevice.haladdress
+ "/HVACService!HVACCmd=Set!HVACName=" + "/HVACService!HVACCmd=Set!HVACName="
@@ -1638,12 +1684,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
$scope.imgButtonsUrl = "glyphicon glyphicon-plus"; $scope.imgButtonsUrl = "glyphicon glyphicon-plus";
}; };
$scope.deleteDeviceByMapId = function (haldevicename, halname, mapType) { $scope.deleteDeviceByMapId = function (id, mapType) {
var id = haldevicename + "-" + halname;
if(mapType == "HOME")
id = id + "-HomeAway";
if(mapType == "HALThermoSet")
id = id + "-SetAuto";
$scope.bridge.mapandid = { id, mapType }; $scope.bridge.mapandid = { id, mapType };
ngDialog.open({ ngDialog.open({
template: 'deleteMapandIdDialog', template: 'deleteMapandIdDialog',
@@ -1906,17 +1947,7 @@ app.filter('unavailableHalDeviceId', function(bridgeService) {
if(input == null) if(input == null)
return out; return out;
for (var i = 0; i < input.length; i++) { for (var i = 0; i < input.length; i++) {
if(bridgeService.findDeviceByMapId(input[i].haldevicename + "-" + input[i].halname, input[i].halname, "halDevice")){ if(input[i].mapType != null && bridgeService.aContainsB(input[i].mapType, "hal")){
out.push(input[i]);
}
}
for (var i = 0; i < input.length; i++) {
if(bridgeService.findDeviceByMapId(input[i].haldevicename + "-" + input[i].halname + "-HomeAway", input[i].halname, "halHome")){
out.push(input[i]);
}
}
for (var i = 0; i < input.length; i++) {
if(input[i].mapType == "HALThermoSet"){
out.push(input[i]); out.push(input[i]);
} }
} }

View File

@@ -71,6 +71,8 @@
<option value="exec">Execute Script/Program</option> <option value="exec">Execute Script/Program</option>
<option value="switch">Switch</option> <option value="switch">Switch</option>
<option value="scene">Scene</option> <option value="scene">Scene</option>
<option value="macro">Macro</option>
<option value="group">Group</option>
<option value="activity">Activity</option> <option value="activity">Activity</option>
<option value="button">Button</option> <option value="button">Button</option>
<option value="thermo">Thermo</option> <option value="thermo">Thermo</option>
@@ -97,6 +99,8 @@
<option value="nestThermoSet">Nest Thermostat</option> <option value="nestThermoSet">Nest Thermostat</option>
<option value="hueDevice">Hue Device</option> <option value="hueDevice">Hue Device</option>
<option value="halDevice">HAL Device</option> <option value="halDevice">HAL Device</option>
<option value="halHome">HAL Home Status</option>
<option value="halThermoSet">HAL Thermostat</option>
</select> </select>
</div> </div>
<button class="btn btn-danger" ng-click="clearDevice()"> <button class="btn btn-danger" ng-click="clearDevice()">

View File

@@ -57,6 +57,8 @@
ng-click="toggleSelectAll()"> Name</span></th> ng-click="toggleSelectAll()"> Name</span></th>
<th sortable-header col="category">Category</th> <th sortable-header col="category">Category</th>
<th sortable-header col="halname">HAL</th> <th sortable-header col="halname">HAL</th>
<th>On Button</th>
<th>Off Button</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
@@ -70,12 +72,27 @@
<td>{{haldevice.haldevicetype}}</td> <td>{{haldevice.haldevicetype}}</td>
<td>{{haldevice.halname}}</td> <td>{{haldevice.halname}}</td>
<td> <td>
<button ng-if="haldevice.haldevicetype === 'Light' || haldevice.haldevicetype === 'Appl' || haldevice.haldevicetype === 'Theatre' || haldevice.haldevicetype === 'Custom'" class="btn btn-success" type="submit" <select name="button-on" id="button-on" ng-model="button_on">
<option ng-repeat="aButtonOn in haldevice.buttons.DeviceElements"
value="{{aButtonOn}}">{{aButtonOn.DeviceName}}</option>
</select>
</td>
<td>
<select name="button-off" id="button-off" ng-model="button_off">
<option ng-repeat="aButtonOff in haldevice.buttons.DeviceElements"
value="{{aButtonOff}}">{{aButtonOff.DeviceName}}</option>
</select>
</td>
<td>
<button ng-if="haldevice.haldevicetype != 'Home' && haldevice.haldevicetype != 'HVAC' && haldevice.haldevicetype != 'IrData'" class="btn btn-success" type="submit"
ng-click="buildDeviceUrls(haldevice, device_dim_control)">Generate ng-click="buildDeviceUrls(haldevice, device_dim_control)">Generate
Bridge Device</button> Bridge Device</button>
<button ng-if="haldevice.haldevicetype === 'HOME'" class="btn btn-success" type="submit" <button ng-if="haldevice.haldevicetype == 'Home'" class="btn btn-success" type="submit"
ng-click="buildHALHomeUrls(haldevice)">Home/Away</button> ng-click="buildHALHomeUrls(haldevice)">Home/Away</button>
<ul ng-if="haldevice.haldevicetype === 'HVAC'" class="list-group"> <button ng-if="haldevice.haldevicetype == 'IrData'" class="btn btn-success" type="submit"
ng-click="buildButtonUrls(haldevice, button_on, button_off)">Build
A Button</button>
<ul ng-if="haldevice.haldevicetype == 'HVAC'" class="list-group">
<li class="list-group-item"> <li class="list-group-item">
<p> <p>
<button class="btn btn-success" type="submit" <button class="btn btn-success" type="submit"
@@ -122,14 +139,14 @@
</tr> </tr>
</thead> </thead>
<tr <tr
ng-repeat="haldevice in bridge.haldevices | unavailableHalDeviceId"> ng-repeat="device in bridge.devices | unavailableHalDeviceId">
<td>{{$index+1}}</td> <td>{{$index+1}}</td>
<td>{{haldevice.haldevicename}}</td> <td>{{device.name}}</td>
<td>{{haldevice.haldevicetype}}</td> <td>{{device.deviceType}}</td>
<td>{{haldevice.halname}}</td> <td>{{device.targetDevice}}</td>
<td> <td>
<button class="btn btn-danger" type="submit" <button class="btn btn-danger" type="submit"
ng-click="deleteDeviceByMapId(haldevice.haldevicename, haldevice.halname, haldevice.haldevicetype)">Delete</button> ng-click="deleteDeviceByMapId(device.mapId, device.mapType)">Delete</button>
</td> </td>
</tr> </tr>
</table> </table>