Compare commits

...

9 Commits

Author SHA1 Message Date
Admin
c773477a43 Added delete dialog for confirmation. Fixed bug with text in
intensity.byte for vera device tab. Fixed issue with parsing replies for
http requests. Fixed Hue device bulk add. recommit


Fixes #100
Fixes #102
Fixes #104
Fixes #105
2016-05-04 11:45:51 -05:00
BWS Systems
5d1f0ce3b6 update versions in unit file 2016-05-02 15:41:01 -05:00
Admin
7e0fd6c21b Updated the register with hue function to not send a user name when
linking as this has been deprecated by Philips.

Fixes #99
2016-04-29 16:12:52 -05:00
BWS Systems
3bf52f5da0 Updated Readme
Added comment for Hue proxy and using the link button.
2016-04-29 12:54:08 -05:00
BWS Systems
bd856d8f9e Fixed spelling 2016-04-29 12:44:30 -05:00
Admin
73b2be752e Issue with http/https handling trying to token out line. Updated Readme
Fixes #96
Fixes #98
2016-04-29 12:27:15 -05:00
Admin
dda7a7a34a Merge remote-tracking branch 'origin/add-color-args' 2016-04-29 11:26:06 -05:00
Admin
f238e05533 Fixed bug where device state object was dropped from hue api device
response object. This caused devices to appear offline and invalid
response interpretation by the echo.

Fixes #93
2016-04-28 12:12:49 -05:00
Admin
9a1924422e Updated Readme 2016-04-27 13:07:49 -05:00
14 changed files with 233 additions and 87 deletions

View File

@@ -35,7 +35,7 @@ After=network.target
[Service] [Service]
Type=simple Type=simple
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/amazon-echo/data/habridge.config /home/pi/amazon-echo/ha-bridge-2.0.0.jar ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/amazon-echo/data/habridge.config /home/pi/amazon-echo/ha-bridge-2.0.3.jar
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
@@ -86,6 +86,8 @@ The user name of the MyHarmony.com account for the Harmony Hub. This needs to be
The password for the user name of the MyHarmony.com account for the Harmony Hub. This needs to be given if you are using the Harmony Hub Features. The password for the user name of the MyHarmony.com account for the Harmony Hub. This needs to be given if you are using the Harmony Hub Features.
#### Hue Names and IP Addresses #### Hue Names and IP Addresses
Provide IP Addresses of your Hue Bridges that you want to proxy through the bridge. Also, give a meaningful name to each one so it is easy to decipher in the helper tab. When these names and IP's are given, the bridge will passthru the call it receives to the target Hue and device you configure. Provide IP Addresses of your Hue Bridges that you want to proxy through the bridge. Also, give a meaningful name to each one so it is easy to decipher in the helper tab. When these names and IP's are given, the bridge will passthru the call it receives to the target Hue and device you configure.
Don't forget - You will need to push the link button when you got to the Hue Tab the first time ater the process comes up. (The user name is not persistent when the process comes up.)
#### Nest Username #### Nest Username
The user name of the home.nest.com account for the Nest user. This needs to be given if you are using the Nest features. There is no need to give any ip address or host information as this contacts your cloud account. The user name of the home.nest.com account for the Nest user. This needs to be given if you are using the Nest features. There is no need to give any ip address or host information as this contacts your cloud account.
#### Nest Password #### Nest Password
@@ -117,7 +119,7 @@ The helper tabs will also show you what you have already configured for that tar
#### The Manual Add Tab #### The Manual Add Tab
Another way to add a device is through the Manual Add Tab. This allows you to manually enter the name, the on and off URLs and select if there are custom handling with the type of call that can be made. This allows for control of anything that has a distinct request that can be executed so you are not limited to the Vera, Harmony, Nest or other Hue. Another way to add a device is through the Manual Add Tab. This allows you to manually enter the name, the on and off URLs and select if there are custom handling with the type of call that can be made. This allows for control of anything that has a distinct request that can be executed so you are not limited to the Vera, Harmony, Nest or other Hue.
The format of these can be the default HTTP request which executes the URLs formatted as http://<your stuff here> as a GET. Other options to this are to select the HTTP Verb and add the data type and add a body that is passed with the request. Secure https is supported as well, just use https://<your secure call here>. When using POST and PUT, you have the ability to specify the body that will be sent with the request as well as the application type for the http call. The format of these can be the default HTTP request which executes the URLs formatted as `http://<your stuff here>` as a GET. Other options to this are to select the HTTP Verb and add the data type and add a body that is passed with the request. Secure https is supported as well, just use `https://<your secure call here>`. When using POST and PUT, you have the ability to specify the body that will be sent with the request as well as the application type for the http call.
Headers can be added as well using a Json construct [{"name":"header type name","value":"the header value"}] with the format example: Headers can be added as well using a Json construct [{"name":"header type name","value":"the header value"}] with the format example:
``` ```
@@ -125,7 +127,7 @@ Headers can be added as well using a Json construct [{"name":"header type name",
{"name":"Pragma","value":"no-cache"}] {"name":"Pragma","value":"no-cache"}]
``` ```
Another option that is detected by the bridge is to use UDP or TCP direct calls such as udp://<ip_address>:<port>/<your stuff here> to send a UDP request. TCP calls are handled the same way as tcp://<ip_address>:<port>/<your stuff here>. If your data for the UDP or TCP request is formatted as "0x00F009B9" lexical hex format, the bridge will convert the data into a binary stream to send. Another option that is detected by the bridge is to use UDP or TCP direct calls such as `udp://<ip_address>:<port>/<your stuff here>` to send a UDP request. TCP calls are handled the same way as `tcp://<ip_address>:<port>/<your stuff here>`. If your data for the UDP or TCP request is formatted as "0x00F009B9" lexical hex format, the bridge will convert the data into a binary stream to send.
You can also use the value replacement constructs within these statements. Such as using the expressions ${intensity.percent} for 0-100 or ${intensity.byte} for 0-255 for straight pass through of the value or items that require special calculated values using ${intensity.math()} i.e. "${intensity.math(X/4)}". You can also use the value replacement constructs within these statements. Such as using the expressions ${intensity.percent} for 0-100 or ${intensity.byte} for 0-255 for straight pass through of the value or items that require special calculated values using ${intensity.math()} i.e. "${intensity.math(X/4)}".
Examples: Examples:
@@ -138,6 +140,14 @@ http://192.168.1.1:8280/set/this
ContentBody: {"someValue":"${intensity..byte}"} ContentBody: {"someValue":"${intensity..byte}"}
udp://192.168.1.1:5000/0x45${intensity.percent}55 udp://192.168.1.1:5000/0x45${intensity.percent}55
udp://192.168.2.2:6000/fireoffthismessage\n
tcp://192.168.3.3:9000/sendthismessage
tcp://192.168.4.4:10000/0x435f12dd${intensity.math((X -4)*50)}438c
tcp://192.168.5.5:110000/0x
``` ```
#### Multiple Call Construct #### Multiple Call Construct
@@ -158,7 +168,7 @@ Format Example in the URL areas:
{"item":"https://192.168.12.1/do/this/secure/thing"}] {"item":"https://192.168.12.1/do/this/secure/thing"}]
``` ```
#### Script or Command Execution #### Script or Command Execution
The release as of v2.0.0 will no support the execution of a local script or program. This will blindly fire off a process to run and is bound by the privileges of the java process. The release as of v2.0.0 will now support the execution of a local script or program. This will blindly fire off a process to run and is bound by the privileges of the java process.
To configure this type of manual add, you will need to select the Device type of "Execute Script/Program". To configure this type of manual add, you will need to select the Device type of "Execute Script/Program".
@@ -951,4 +961,4 @@ To turn on debugging for the bridge, use the following extra parm in the command
To turn on development mode so that it will not need an Harmony Hub for testing, use the following extra parm in the command line and the harmony ip and login info will not be needed: To turn on development mode so that it will not need an Harmony Hub for testing, use the following extra parm in the command line and the harmony ip and login info will not be needed:
``` ```
java -jar -Ddev.mode=true ha-bridge-0.X.Y.jar java -jar -Ddev.mode=true ha-bridge-0.X.Y.jar
``` ```

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.0</version> <version>2.0.4</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>HA Bridge</name> <name>HA Bridge</name>

View File

@@ -1,5 +1,6 @@
package com.bwssystems.HABridge.api.hue; package com.bwssystems.HABridge.api.hue;
// import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@@ -7,7 +8,7 @@ import java.util.List;
*/ */
public class DeviceState { public class DeviceState {
private boolean on; private boolean on;
private int bri = 255; private int bri;
private int hue; private int hue;
private int sat; private int sat;
private String effect; private String effect;
@@ -96,7 +97,24 @@ public class DeviceState {
public void setXy(List<Double> xy) { public void setXy(List<Double> xy) {
this.xy = xy; this.xy = xy;
} }
public static DeviceState createDeviceState() {
DeviceState newDeviceState = new DeviceState();
newDeviceState.fillIn();
// newDeviceState.setColormode("none");
// ArrayList<Double> doubleArray = new ArrayList<Double>();
// doubleArray.add(new Double(0));
// doubleArray.add(new Double(0));
// newDeviceState.setXy(doubleArray);
return newDeviceState;
}
public void fillIn() {
if(this.getAlert() == null)
this.setAlert("none");
if(this.getEffect() == null)
this.setEffect("none");
this.setReachable(true);
}
@Override @Override
public String toString() { public String toString() {
return "DeviceState{" + return "DeviceState{" +

View File

@@ -166,6 +166,8 @@ public class DeviceDescriptor{
} }
public DeviceState getDeviceState() { public DeviceState getDeviceState() {
if(deviceState == null)
deviceState = DeviceState.createDeviceState();
return deviceState; return deviceState;
} }

View File

@@ -381,6 +381,7 @@ public class HueMulator implements HueErrorStringSet {
responseString = "[{\"error\":{\"type\": 3, \"address\": \"/lights/" + lightId + "\",\"description\": \"Could not find device\", \"resource\": \"/lights/" + lightId + "\"}}]"; responseString = "[{\"error\":{\"type\": 3, \"address\": \"/lights/" + lightId + "\",\"description\": \"Could not find device\", \"resource\": \"/lights/" + lightId + "\"}}]";
return responseString; return responseString;
} }
state.fillIn();
theHeaders = new Gson().fromJson(device.getHeaders(), NameValue[].class); theHeaders = new Gson().fromJson(device.getHeaders(), NameValue[].class);
responseString = this.formatSuccessHueResponse(state, request.body(), lightId); responseString = this.formatSuccessHueResponse(state, request.body(), lightId);
@@ -582,41 +583,43 @@ public class HueMulator implements HueErrorStringSet {
Thread.sleep(bridgeSettings.getButtonsleep()); Thread.sleep(bridgeSettings.getButtonsleep());
} }
try { try {
String intermediate = callItems[i].getItem().substring(callItems[i].getItem().indexOf("://") + 3); if(callItems[i].getItem().contains("udp://") || callItems[i].getItem().contains("tcp://")) {
String hostPortion = intermediate.substring(0, intermediate.indexOf('/')); String intermediate = callItems[i].getItem().substring(callItems[i].getItem().indexOf("://") + 3);
String theUrlBody = intermediate.substring(intermediate.indexOf('/')+1); String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
String hostAddr = null; String theUrlBody = intermediate.substring(intermediate.indexOf('/')+1);
String port = null; String hostAddr = null;
if(hostPortion.contains(":")) { String port = null;
hostAddr = hostPortion.substring(0, intermediate.indexOf(':')); if(hostPortion.contains(":")) {
port = hostPortion.substring(intermediate.indexOf(':') + 1); hostAddr = hostPortion.substring(0, intermediate.indexOf(':'));
} port = hostPortion.substring(intermediate.indexOf(':') + 1);
else }
hostAddr = hostPortion; else
InetAddress IPAddress = InetAddress.getByName(hostAddr);; hostAddr = hostPortion;
if(theUrlBody.startsWith("0x")) { InetAddress IPAddress = InetAddress.getByName(hostAddr);;
theUrlBody = replaceIntensityValue(theUrlBody, state.getBri(), true); if(theUrlBody.startsWith("0x")) {
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2)); theUrlBody = replaceIntensityValue(theUrlBody, state.getBri(), true);
} sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
else { }
theUrlBody = replaceIntensityValue(theUrlBody, state.getBri(), false); else {
sendData = theUrlBody.getBytes(); theUrlBody = replaceIntensityValue(theUrlBody, state.getBri(), false);
} sendData = theUrlBody.getBytes();
if(callItems[i].getItem().contains("udp://")) { }
log.debug("executing HUE api request to UDP: " + callItems[i].getItem()); if(callItems[i].getItem().contains("udp://")) {
DatagramSocket responseSocket = new DatagramSocket(Integer.parseInt(port)); log.debug("executing HUE api request to UDP: " + callItems[i].getItem());
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, Integer.parseInt(port)); DatagramSocket responseSocket = new DatagramSocket(Integer.parseInt(port));
responseSocket.send(sendPacket); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, Integer.parseInt(port));
responseSocket.close(); responseSocket.send(sendPacket);
} responseSocket.close();
else if(callItems[i].getItem().contains("tcp://")) }
{ else if(callItems[i].getItem().contains("tcp://"))
log.debug("executing HUE api request to TCP: " + callItems[i].getItem()); {
Socket dataSendSocket = new Socket(IPAddress, Integer.parseInt(port)); log.debug("executing HUE api request to TCP: " + callItems[i].getItem());
DataOutputStream outToClient = new DataOutputStream(dataSendSocket.getOutputStream()); Socket dataSendSocket = new Socket(IPAddress, Integer.parseInt(port));
outToClient.write(sendData); DataOutputStream outToClient = new DataOutputStream(dataSendSocket.getOutputStream());
outToClient.flush(); outToClient.write(sendData);
dataSendSocket.close(); outToClient.flush();
dataSendSocket.close();
}
} }
else { else {
log.debug("executing HUE api request to Http " + (device.getHttpVerb() == null?"GET":device.getHttpVerb()) + ": " + callItems[i].getItem()); log.debug("executing HUE api request to Http " + (device.getHttpVerb() == null?"GET":device.getHttpVerb()) + ": " + callItems[i].getItem());
@@ -749,8 +752,10 @@ public class HueMulator implements HueErrorStringSet {
response = httpClient.execute(request); response = httpClient.execute(request);
log.debug((httpVerb == null?"GET":httpVerb) + " execute on URL responded: " + response.getStatusLine().getStatusCode()); log.debug((httpVerb == null?"GET":httpVerb) + " execute on URL responded: " + response.getStatusLine().getStatusCode());
if(response.getStatusLine().getStatusCode() >= 200 && response.getStatusLine().getStatusCode() < 300){ if(response.getStatusLine().getStatusCode() >= 200 && response.getStatusLine().getStatusCode() < 300){
theContent = EntityUtils.toString(response.getEntity(), Charset.forName("UTF-8")); //read content for data if(response.getEntity() != null ) {
EntityUtils.consume(response.getEntity()); //close out inputstream ignore content theContent = EntityUtils.toString(response.getEntity(), Charset.forName("UTF-8")); //read content for data
EntityUtils.consume(response.getEntity()); //close out inputstream ignore content
}
} }
} catch (IOException e) { } catch (IOException e) {
log.warn("Error calling out to HA gateway: IOException in log", e); log.warn("Error calling out to HA gateway: IOException in log", e);

View File

@@ -21,11 +21,7 @@ public class HueUtil {
public static final String registerWithHue(HttpClient anHttpClient, String ipAddress, String aName, String theUser, HueErrorStringSet errorStringSet) { public static final String registerWithHue(HttpClient anHttpClient, String ipAddress, String aName, String theUser, HueErrorStringSet errorStringSet) {
UserCreateRequest theLogin = new UserCreateRequest(); UserCreateRequest theLogin = new UserCreateRequest();
theLogin.setDevicetype("HA Bridge"); theLogin.setDevicetype("HABridge#MyMachine");
if(theUser == null)
theLogin.setUsername("habridge");
else
theLogin.setUsername(theUser);
HttpPost postRequest = new HttpPost("http://" + ipAddress + HUE_REQUEST); HttpPost postRequest = new HttpPost("http://" + ipAddress + HUE_REQUEST);
ContentType parsedContentType = ContentType.parse("application/json"); ContentType parsedContentType = ContentType.parse("application/json");
StringEntity requestBody = new StringEntity(new Gson().toJson(theLogin), parsedContentType); StringEntity requestBody = new StringEntity(new Gson().toJson(theLogin), parsedContentType);

View File

@@ -47,7 +47,7 @@ app.run( function (bridgeService) {
app.service('bridgeService', function ($http, $window, ngToast) { app.service('bridgeService', function ($http, $window, ngToast) {
var self = this; var self = this;
this.state = {base: window.location.origin + "/api/devices", bridgelocation: window.location.origin, systemsbase: window.location.origin + "/system", huebase: window.location.origin + "/api", configs: [], backups: [], devices: [], device: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], olddevicename: "", logShowAll: false, isInControl: false, showVera: false, showHarmony: false, showNest: false, showHue: false, habridgeversion: ""}; this.state = {base: window.location.origin + "/api/devices", bridgelocation: window.location.origin, systemsbase: window.location.origin + "/system", huebase: window.location.origin + "/api", configs: [], backups: [], devices: [], device: [], mapandid: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], olddevicename: "", logShowAll: false, isInControl: false, showVera: false, showHarmony: false, showNest: false, showHue: false, habridgeversion: ""};
this.displayWarn = function(errorTitle, error) { this.displayWarn = function(errorTitle, error) {
var toastContent = errorTitle; var toastContent = errorTitle;
@@ -324,6 +324,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
this.bulkAddDevice = function (devices) { this.bulkAddDevice = function (devices) {
return $http.post(this.state.base, devices).then( return $http.post(this.state.base, devices).then(
function (response) { function (response) {
self.displaySuccess("Bulk device add successful.");
}, },
function (error) { function (error) {
self.displayWarn("Bulk Add new Device Error: ", error); self.displayWarn("Bulk Add new Device Error: ", error);
@@ -724,7 +725,12 @@ app.controller('ViewingController', function ($scope, $location, $http, $window,
bridgeService.testUrl(device, type); bridgeService.testUrl(device, type);
}; };
$scope.deleteDevice = function (device) { $scope.deleteDevice = function (device) {
bridgeService.deleteDevice(device.id); $scope.bridge.device = device;
ngDialog.open({
template: 'deleteDialog',
controller: 'DeleteDialogCtrl',
className: 'ngdialog-theme-default'
});
}; };
$scope.editDevice = function (device) { $scope.editDevice = function (device) {
bridgeService.editDevice(device); bridgeService.editDevice(device);
@@ -789,7 +795,36 @@ app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
}; };
}); });
app.controller('VeraController', function ($scope, $location, $http, bridgeService) { app.controller('DeleteDialogCtrl', function ($scope, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state;
$scope.device = $scope.bridge.device;
$scope.deleteDevice = function (device) {
ngDialog.close('ngdialog1');
bridgeService.deleteDevice(device.id);
bridgeService.viewDevices();
$scope.bridge.device = null;
$scope.bridge.type = "";
};
});
app.controller('DeleteMapandIdDialogCtrl', function ($scope, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state;
$scope.mapandid = $scope.bridge.mapandid;
$scope.deleteMapandId = function (mapandid) {
ngDialog.close('ngdialog1');
bridgeService.deleteDeviceByMapId(mapandid.id, mapandid.mapType);
bridgeService.viewDevices();
bridgeService.viewVeraDevices();
bridgeService.viewVeraScenes();
bridgeService.viewHarmonyActivities();
bridgeService.viewHarmonyDevices();
bridgeService.viewNestItems();
bridgeService.viewHueDevices();
$scope.bridge.mapandid = null;
};
});
app.controller('VeraController', function ($scope, $location, $http, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state; $scope.bridge = bridgeService.state;
$scope.device = $scope.bridge.device; $scope.device = $scope.bridge.device;
$scope.device_dim_control = ""; $scope.device_dim_control = "";
@@ -919,15 +954,17 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi
}; };
$scope.deleteDeviceByMapId = function (id, mapType) { $scope.deleteDeviceByMapId = function (id, mapType) {
bridgeService.deleteDeviceByMapId(id, mapType); $scope.bridge.mapandid = { id, mapType };
bridgeService.viewDevices(); ngDialog.open({
bridgeService.viewVeraDevices(); template: 'deleteMapandIdDialog',
bridgeService.viewVeraScenes(); controller: 'DeleteMapandIdDialogCtrl',
className: 'ngdialog-theme-default'
});
}; };
}); });
app.controller('HarmonyController', function ($scope, $location, $http, bridgeService) { app.controller('HarmonyController', function ($scope, $location, $http, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state; $scope.bridge = bridgeService.state;
$scope.device = $scope.bridge.device; $scope.device = $scope.bridge.device;
bridgeService.viewHarmonyActivities(); bridgeService.viewHarmonyActivities();
@@ -996,15 +1033,17 @@ app.controller('HarmonyController', function ($scope, $location, $http, bridgeSe
}; };
$scope.deleteDeviceByMapId = function (id, mapType) { $scope.deleteDeviceByMapId = function (id, mapType) {
bridgeService.deleteDeviceByMapId(id, mapType); $scope.bridge.mapandid = { id, mapType };
bridgeService.viewDevices(); ngDialog.open({
bridgeService.viewHarmonyActivities(); template: 'deleteMapandIdDialog',
bridgeService.viewHarmonyDevices(); controller: 'DeleteMapandIdDialogCtrl',
className: 'ngdialog-theme-default'
});
}; };
}); });
app.controller('NestController', function ($scope, $location, $http, bridgeService) { app.controller('NestController', function ($scope, $location, $http, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state; $scope.bridge = bridgeService.state;
$scope.device = $scope.bridge.device; $scope.device = $scope.bridge.device;
bridgeService.viewNestItems(); bridgeService.viewNestItems();
@@ -1116,14 +1155,17 @@ app.controller('NestController', function ($scope, $location, $http, bridgeServi
}; };
$scope.deleteDeviceByMapId = function (id, mapType) { $scope.deleteDeviceByMapId = function (id, mapType) {
bridgeService.deleteDeviceByMapId(id, mapType); $scope.bridge.mapandid = { id, mapType };
bridgeService.viewDevices(); ngDialog.open({
bridgeService.viewNestItems(); template: 'deleteMapandIdDialog',
controller: 'DeleteMapandIdDialogCtrl',
className: 'ngdialog-theme-default'
});
}; };
}); });
app.controller('HueController', function ($scope, $location, $http, bridgeService) { app.controller('HueController', function ($scope, $location, $http, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state; $scope.bridge = bridgeService.state;
$scope.device = $scope.bridge.device; $scope.device = $scope.bridge.device;
$scope.bulk = { devices: [] }; $scope.bulk = { devices: [] };
@@ -1168,7 +1210,7 @@ app.controller('HueController', function ($scope, $location, $http, bridgeServic
var devicesList = []; var devicesList = [];
for(var i = 0; i < $scope.bulk.devices.length; i++) { for(var i = 0; i < $scope.bulk.devices.length; i++) {
for(var x = 0; x < bridgeService.state.huedevices.length; x++) { for(var x = 0; x < bridgeService.state.huedevices.length; x++) {
if(bridgeService.state.huedevices[x].id == $scope.bulk.devices[i]) { if(bridgeService.state.huedevices[x].device.uniqueid == $scope.bulk.devices[i]) {
$scope.buildDeviceUrls(bridgeService.state.huedevices[x]); $scope.buildDeviceUrls(bridgeService.state.huedevices[x]);
devicesList[i] = { devicesList[i] = {
name: $scope.device.name, name: $scope.device.name,
@@ -1217,9 +1259,12 @@ app.controller('HueController', function ($scope, $location, $http, bridgeServic
}; };
$scope.deleteDeviceByMapId = function (id, mapType) { $scope.deleteDeviceByMapId = function (id, mapType) {
bridgeService.deleteDeviceByMapId(id, mapType); $scope.bridge.mapandid = { id, mapType };
bridgeService.viewDevices(); ngDialog.open({
bridgeService.viewHueDevices(); template: 'deleteMapandIdDialog',
controller: 'DeleteMapandIdDialogCtrl',
className: 'ngdialog-theme-default'
});
}; };
}); });

View File

@@ -103,4 +103,14 @@
<button type="button" class="ngdialog-button ngdialog-button-primary" ng-click="setValue()">Set</button> <button type="button" class="ngdialog-button ngdialog-button-primary" ng-click="setValue()">Set</button>
</div> </div>
</script> </script>
<script type="text/ng-template" id="deleteDialog">
<div class="ngdialog-message">
<h2>Device to Delete?</h2>
<p>{{device.name}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteDevice(device)">Delete</button>
</div>
</script>

View File

@@ -11,7 +11,7 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li> <li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul> </ul>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Harmony Activity List</h2> <h2 class="panel-title">Harmony Activity List</h2>
</div> </div>
@@ -75,7 +75,7 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Add a Bridge Device for a Harmony Activity</h2> <h2 class="panel-title">Add a Bridge Device for a Harmony Activity</h2>
</div> </div>
@@ -121,3 +121,13 @@
</li> </li>
</ul> </ul>
</div> </div>
<script type="text/ng-template" id="deleteMapandIdDialog">
<div class="ngdialog-message">
<h2>Device Map and Id?</h2>
<p>{{mapandid.mapType}} with {{mapandid.id}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteMapandId(mapandid)">Delete</button>
</div>
</script>

View File

@@ -11,7 +11,7 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li> <li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul> </ul>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Harmony Device List</h2> <h2 class="panel-title">Harmony Device List</h2>
</div> </div>
@@ -96,7 +96,7 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Add a Bridge Device for Harmony Buttons</h2> <h2 class="panel-title">Add a Bridge Device for Harmony Buttons</h2>
</div> </div>
@@ -142,3 +142,13 @@
</li> </li>
</ul> </ul>
</div> </div>
<script type="text/ng-template" id="deleteMapandIdDialog">
<div class="ngdialog-message">
<h2>Device Map and Id?</h2>
<p>{{mapandid.mapType}} with {{mapandid.id}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteMapandId(mapandid)">Delete</button>
</div>
</script>

View File

@@ -11,7 +11,7 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li> <li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul> </ul>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Hue Device List ({{bridge.huedevices.length}})</h2> <h2 class="panel-title">Hue Device List ({{bridge.huedevices.length}})</h2>
</div> </div>
@@ -36,7 +36,7 @@
</thead> </thead>
<tr ng-repeat="huedevice in bridge.huedevices | availableHueDeviceId"> <tr ng-repeat="huedevice in bridge.huedevices | availableHueDeviceId">
<td>{{$index+1}}</td> <td>{{$index+1}}</td>
<td><input type="checkbox" name="bulk.devices[]" value="{{huedevice.id}}" ng-checked="bulk.devices.indexOf(huedevice.id) > -1" ng-click="toggleSelection(huedevice.id)"> {{huedevice.device.name}}</td> <td><input type="checkbox" name="bulk.devices[]" value="{{huedevice.device.uniqueid}}" ng-checked="bulk.devices.indexOf(huedevice.device.uniqueid) > -1" ng-click="toggleSelection(huedevice.device.uniqueid)"> {{huedevice.device.name}}</td>
<td>{{huedevice.device.uniqueid}}</td> <td>{{huedevice.device.uniqueid}}</td>
<td>{{huedevice.huename}}</td> <td>{{huedevice.huename}}</td>
<td> <td>
@@ -48,7 +48,7 @@
</scrollable-table> </scrollable-table>
<p> <p>
<button class="btn btn-success" type="submit" <button class="btn btn-success" type="submit"
ng-click="bulkHueDevices()">Bulk Add ({{bulk.devices.length}})</button> ng-click="bulkAddDevices()">Bulk Add ({{bulk.devices.length}})</button>
</p> </p>
</li> </li>
</ul> </ul>
@@ -75,7 +75,7 @@
<td>{{huedevice.huename}}</td> <td>{{huedevice.huename}}</td>
<td> <td>
<button class="btn btn-danger" type="submit" <button class="btn btn-danger" type="submit"
ng-click="deleteDeviceByMapId(huedevice.uniqueid, 'hueDevice')">Delete</button> ng-click="deleteDeviceByMapId(huedevice.device.uniqueid, 'hueDevice')">Delete</button>
</td> </td>
</tr> </tr>
</table> </table>
@@ -83,7 +83,7 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Add Bridge Device for a Hue Device</h2> <h2 class="panel-title">Add Bridge Device for a Hue Device</h2>
</div> </div>
@@ -117,3 +117,13 @@
</li> </li>
</ul> </ul>
</div> </div>
<script type="text/ng-template" id="deleteMapandIdDialog">
<div class="ngdialog-message">
<h2>Device Map and Id?</h2>
<p>{{mapandid.mapType}} with {{mapandid.id}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteMapandId(mapandid)">Delete</button>
</div>
</script>

View File

@@ -11,7 +11,7 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li> <li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul> </ul>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Nest Items List</h2> <h2 class="panel-title">Nest Items List</h2>
</div> </div>
@@ -97,7 +97,7 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Add a Bridge Device for a Nest Item</h2> <h2 class="panel-title">Add a Bridge Device for a Nest Item</h2>
</div> </div>
@@ -143,3 +143,13 @@
</li> </li>
</ul> </ul>
</div> </div>
<script type="text/ng-template" id="deleteMapandIdDialog">
<div class="ngdialog-message">
<h2>Device Map and Id?</h2>
<p>{{mapandid.mapType}} with {{mapandid.id}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteMapandId(mapandid)">Delete</button>
</div>
</script>

View File

@@ -11,7 +11,7 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li> <li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul> </ul>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Vera Device List ({{bridge.veradevices.length}})</h2> <h2 class="panel-title">Vera Device List ({{bridge.veradevices.length}})</h2>
</div> </div>
@@ -24,7 +24,7 @@
control you would like to be generated: control you would like to be generated:
<select name="device-dim-control" id="device-dim-control" ng-model="device_dim_control"> <select name="device-dim-control" id="device-dim-control" ng-model="device_dim_control">
<option value="">none</option> <option value="">none</option>
<option value="${intensity..byte}">Pass-thru Value</option> <option value="${intensity.byte}">Pass-thru Value</option>
<option value="${intensity.percent}">Percentage</option> <option value="${intensity.percent}">Percentage</option>
<option value="${intensity.math(X*1)}">Custom Math</option> <option value="${intensity.math(X*1)}">Custom Math</option>
</select> </select>
@@ -100,7 +100,7 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Add Bridge Device for a Vera Device</h2> <h2 class="panel-title">Add Bridge Device for a Vera Device</h2>
</div> </div>
@@ -155,3 +155,13 @@
</li> </li>
</ul> </ul>
</div> </div>
<script type="text/ng-template" id="deleteMapandIdDialog">
<div class="ngdialog-message">
<h2>Device Map and Id?</h2>
<p>{{mapandid.mapType}} with {{mapandid.id}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteMapandId(mapandid)">Delete</button>
</div>
</script>

View File

@@ -11,7 +11,7 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li> <li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul> </ul>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Vera Scene List</h2> <h2 class="panel-title">Vera Scene List</h2>
</div> </div>
@@ -81,7 +81,7 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error"> <div class="panel panel-default bridgeServer">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Add a Bridge Device for a Vera scene</h2> <h2 class="panel-title">Add a Bridge Device for a Vera scene</h2>
</div> </div>
@@ -125,3 +125,13 @@
</li> </li>
</ul> </ul>
</div> </div>
<script type="text/ng-template" id="deleteMapandIdDialog">
<div class="ngdialog-message">
<h2>Device Map and Id?</h2>
<p>{{mapandid.mapType}} with {{mapandid.id}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteMapandId(mapandid)">Delete</button>
</div>
</script>