javascript updates

This commit is contained in:
Admin
2017-01-04 11:21:23 -06:00
parent 5a292c98a2
commit a0a2d90617
2 changed files with 141 additions and 144 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>4beta2.4</version> <version>4beta2.5</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>HA Bridge</name> <name>HA Bridge</name>

View File

@@ -73,8 +73,8 @@ app.service('bridgeService', function ($http, $window, ngToast) {
this.displayWarn = function(errorTitle, error) { this.displayWarn = function(errorTitle, error) {
var toastContent = errorTitle; var toastContent = errorTitle;
if(error != null && typeof(error) != 'undefined') { if (error !== null && typeof(error) !== 'undefined') {
if(error.data != null) if (error.data !== null)
toastContent = toastContent + " " + error.data.message + " with status: " + error.statusText + " - " + error.status; toastContent = toastContent + " " + error.data.message + " with status: " + error.statusText + " - " + error.status;
else else
toastContent = error; toastContent = error;
@@ -88,7 +88,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
this.displayError = function(errorTitle, error) { this.displayError = function(errorTitle, error) {
var toastContent = errorTitle; var toastContent = errorTitle;
if(error != null && typeof(error) != 'undefined') if (error !== null && typeof(error) !== 'undefined')
toastContent = toastContent + " " + error.data.message + " with status: " + error.statusText + " - " + error.status; toastContent = toastContent + " " + error.data.message + " with status: " + error.statusText + " - " + error.status;
ngToast.create({ ngToast.create({
className: "danger", className: "danger",
@@ -134,7 +134,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
}; };
this.clearDevice = function () { this.clearDevice = function () {
if(self.state.device == null) if(self.state.device === null)
self.state.device = []; self.state.device = [];
self.state.device.id = ""; self.state.device.id = "";
self.state.device.mapType = null; self.state.device.mapType = null;
@@ -152,7 +152,6 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.state.device.contentBody = null; self.state.device.contentBody = null;
self.state.device.contentBodyDim = null; self.state.device.contentBodyDim = null;
self.state.device.contentBodyOff = null; self.state.device.contentBodyOff = null;
self.state.device.requesterAddress = null;
self.state.olddevicename = ""; self.state.olddevicename = "";
}; };
@@ -401,7 +400,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
for (i=0; i<len; ++i) { for (i=0; i<len; ++i) {
if (i in self.state.mapTypes) { if (i in self.state.mapTypes) {
s = self.state.mapTypes[i]; s = self.state.mapTypes[i];
if(aMapType == s[0]) if (aMapType === s[0])
return self.state.mapTypes[i]; return self.state.mapTypes[i];
} }
} }
@@ -422,7 +421,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
this.findDeviceByMapId = function (id, target, type) { this.findDeviceByMapId = function (id, target, type) {
for (var i = 0; i < this.state.devices.length; i++) { for (var i = 0; i < this.state.devices.length; i++) {
if(this.state.devices[i].mapId == id && this.state.devices[i].mapType == type && this.state.devices[i].targetDevice == target) if (this.state.devices[i].mapId === id && this.state.devices[i].mapType === type && this.state.devices[i].targetDevice === target)
return true; return true;
} }
return false; return false;
@@ -430,7 +429,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
this.findNestItemByMapId = function (id, type) { this.findNestItemByMapId = function (id, type) {
for (var i = 0; i < this.state.devices.length; i++) { for (var i = 0; i < this.state.devices.length; i++) {
if(this.state.devices[i].mapId == id && this.aContainsB(this.state.devices[i].mapType, type)) if (this.state.devices[i].mapId === id && this.aContainsB(this.state.devices[i].mapType, type))
return true; return true;
} }
return false; return false;
@@ -450,9 +449,9 @@ app.service('bridgeService', function ($http, $window, ngToast) {
this.addDevice = function (aDevice) { this.addDevice = function (aDevice) {
var device = {}; var device = {};
angular.extend(device, aDevice ); angular.extend(device, aDevice );
if(device.httpVerb != null && device.httpVerb != "") if (device.httpVerb !== null && device.httpVerb !== "")
device.deviceType = "custom"; device.deviceType = "custom";
if(device.targetDevice == null || device.targetDevice == "") if (device.targetDevice === null || device.targetDevice === "")
device.targetDevice = "Encapsulated"; device.targetDevice = "Encapsulated";
if (device.id) { if (device.id) {
var putUrl = this.state.base + "/" + device.id; var putUrl = this.state.base + "/" + device.id;
@@ -464,7 +463,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
} }
); );
} else { } else {
if(device.deviceType == null || device.deviceType == "") if (device.deviceType === null || device.deviceType === "")
device.deviceType = "custom"; device.deviceType = "custom";
return $http.post(this.state.base, device).then( return $http.post(this.state.base, device).then(
function (response) { function (response) {
@@ -631,7 +630,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
this.deleteDeviceByMapId = function (id, type) { this.deleteDeviceByMapId = function (id, type) {
for (var i = 0; i < this.state.devices.length; i++) { for (var i = 0; i < this.state.devices.length; i++) {
if(this.state.devices[i].mapId == id && this.aContainsB(this.state.devices[i].mapType, type)) if (this.state.devices[i].mapId === id && this.aContainsB(this.state.devices[i].mapType, type))
return self.deleteDevice(this.state.devices[i].id); return self.deleteDevice(this.state.devices[i].id);
} }
}; };
@@ -645,10 +644,9 @@ app.service('bridgeService', function ($http, $window, ngToast) {
var msgDescription = "unknown"; var msgDescription = "unknown";
var testUrl = this.state.huebase + "/test/lights/" + device.id + "/state"; var testUrl = this.state.huebase + "/test/lights/" + device.id + "/state";
var testBody = "{\"on\":"; var testBody = "{\"on\":";
if(type == "off") { if (type === "off") {
testBody = testBody + "false"; testBody = testBody + "false";
} } else {
else {
testBody = testBody + "true"; testBody = testBody + "true";
} }
if (value) { if (value) {
@@ -657,10 +655,10 @@ app.service('bridgeService', function ($http, $window, ngToast) {
testBody = testBody + "}"; testBody = testBody + "}";
$http.put(testUrl, testBody).then( $http.put(testUrl, testBody).then(
function (response) { function (response) {
if(typeof(response.data[0].success) != 'undefined') { if (typeof(response.data[0].success) !== 'undefined') {
msgDescription = "success " + angular.toJson(response.data[0].success); msgDescription = "success " + angular.toJson(response.data[0].success);
} }
if(typeof(response.data[0].error) != 'undefined') { if (typeof(response.data[0].error) !== 'undefined') {
msgDescription = "error " + angular.toJson(response.data[0].error); msgDescription = "error " + angular.toJson(response.data[0].error);
self.displayErrorMessage("Request Error, Pleae look in your habridge log: ", msgDescription); self.displayErrorMessage("Request Error, Pleae look in your habridge log: ", msgDescription);
return; return;
@@ -679,10 +677,10 @@ app.service('bridgeService', function ($http, $window, ngToast) {
var currentOn = self.state.device.onUrl; var currentOn = self.state.device.onUrl;
var currentDim = self.state.device.dimUrl; var currentDim = self.state.device.dimUrl;
var currentOff = self.state.device.offUrl; var currentOff = self.state.device.offUrl;
if(self.state.device.mapType !== undefined && self.state.device.mapType != null && self.state.device.mapType != "") { if (self.state.device.mapType !== undefined && self.state.device.mapType !== null && self.state.device.mapType !== "") {
self.state.device.mapId = self.state.device.mapId + "-" + anId; self.state.device.mapId = self.state.device.mapId + "-" + anId;
if(dimpayload != null) { if (dimpayload !== null) {
if(currentDim.indexOf("{\"item") != 1 ) { if (currentDim.indexOf("{\"item") !== 1 ) {
if (isObject) if (isObject)
currentDim = "[{\"item\":" + currentDim + ",\"type\":\"" + deviceMapType + "\"}]"; currentDim = "[{\"item\":" + currentDim + ",\"type\":\"" + deviceMapType + "\"}]";
else else
@@ -692,7 +690,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.state.device.dimUrl = currentDim.substr(0, currentDim.indexOf("]")) + ",{\"item\":"; self.state.device.dimUrl = currentDim.substr(0, currentDim.indexOf("]")) + ",{\"item\":";
} }
if(currentOn.indexOf("{\"item") != 1 ) { if (currentOn.indexOf("{\"item") !== 1 ) {
if (isObject) if (isObject)
currentOn = "[{\"item\":" + currentOn + ",\"type\":\"" + deviceMapType + "\"}]"; currentOn = "[{\"item\":" + currentOn + ",\"type\":\"" + deviceMapType + "\"}]";
else else
@@ -700,53 +698,52 @@ app.service('bridgeService', function ($http, $window, ngToast) {
} }
self.state.device.onUrl = currentOn.substr(0, currentOn.indexOf("]")) + ",{\"item\":"; self.state.device.onUrl = currentOn.substr(0, currentOn.indexOf("]")) + ",{\"item\":";
if(currentOff.indexOf("{\"item") != 1 ) { if (currentOff.indexOf("{\"item") !== 1 ) {
if (isObject) if (isObject)
currentOff = "[{\"item\":" + currentOff + ",\"type\":\"" + deviceMapType + "\"}]"; currentOff = "[{\"item\":" + currentOff + ",\"type\":\"" + deviceMapType + "\"}]";
else else
currentOff = "[{\"item\":\"" + currentOff + "\",\"type\":\"" + deviceMapType + "\"}]"; currentOff = "[{\"item\":\"" + currentOff + "\",\"type\":\"" + deviceMapType + "\"}]";
} }
self.state.device.offUrl = currentOff.substr(0, currentOff.indexOf("]")) + ",{\"item\":"; self.state.device.offUrl = currentOff.substr(0, currentOff.indexOf("]")) + ",{\"item\":";
} } else if (self.state.device.mapType ==== undefined || self.state.device.mapType === null || self.state.device.mapType === "") {
else if (self.state.device.mapType === undefined || self.state.device.mapType == null || self.state.device.mapType == "") {
this.clearDevice(); this.clearDevice();
self.state.device.deviceType = deviceType; self.state.device.deviceType = deviceType;
self.state.device.name = deviceName; self.state.device.name = deviceName;
self.state.device.targetDevice = deviceTarget; self.state.device.targetDevice = deviceTarget;
self.state.device.mapType = deviceMapType; self.state.device.mapType = deviceMapType;
self.state.device.mapId = anId; self.state.device.mapId = anId;
if(dimpayload != null) if(dimpayload !== null)
self.state.device.dimUrl = "[{\"item\":"; self.state.device.dimUrl = "[{\"item\":";
self.state.device.onUrl = "[{\"item\":"; self.state.device.onUrl = "[{\"item\":";
self.state.device.offUrl = "[{\"item\":"; self.state.device.offUrl = "[{\"item\":";
} }
if (isObject) { if (isObject) {
if(dimpayload != null) if (dimpayload !== null)
self.state.device.dimUrl = self.state.device.dimUrl + dimpayload; self.state.device.dimUrl = self.state.device.dimUrl + dimpayload;
self.state.device.onUrl = self.state.device.onUrl + onpayload; self.state.device.onUrl = self.state.device.onUrl + onpayload;
self.state.device.offUrl = self.state.device.offUrl + offpayload; self.state.device.offUrl = self.state.device.offUrl + offpayload;
} else { } else {
if(dimpayload != null) if (dimpayload !== null)
self.state.device.dimUrl = self.state.device.dimUrl + "\"" + dimpayload + "\""; self.state.device.dimUrl = self.state.device.dimUrl + "\"" + dimpayload + "\"";
self.state.device.onUrl = self.state.device.onUrl + "\"" + onpayload + "\""; self.state.device.onUrl = self.state.device.onUrl + "\"" + onpayload + "\"";
self.state.device.offUrl = self.state.device.offUrl + "\"" + offpayload + "\""; self.state.device.offUrl = self.state.device.offUrl + "\"" + offpayload + "\"";
} }
if(count !== undefined && count != null && count != "") { if (count !== undefined && count !== null && count !== "") {
if(dimpayload != null) if (dimpayload !== null)
self.state.device.dimUrl = self.state.device.dimUrl + ",\"count\":\"" + count; self.state.device.dimUrl = self.state.device.dimUrl + ",\"count\":\"" + count;
self.state.device.onUrl = self.state.device.onUrl + ",\"count\":\"" + count; self.state.device.onUrl = self.state.device.onUrl + ",\"count\":\"" + count;
self.state.device.offUrl = self.state.device.offUrl + ",\"count\":\"" + count; self.state.device.offUrl = self.state.device.offUrl + ",\"count\":\"" + count;
} }
if(delay !== undefined && delay != null && delay != "") { if (delay !== undefined && delay !== null && delay !== "") {
if(dimpayload != null) if (dimpayload !== null)
self.state.device.dimUrl = self.state.device.dimUrl + ",\"delay\":\"" + delay; self.state.device.dimUrl = self.state.device.dimUrl + ",\"delay\":\"" + delay;
self.state.device.onUrl = self.state.device.onUrl + ",\"delay\":\"" + delay; self.state.device.onUrl = self.state.device.onUrl + ",\"delay\":\"" + delay;
self.state.device.offUrl = self.state.device.offUrl + ",\"delay\":\"" + delay; self.state.device.offUrl = self.state.device.offUrl + ",\"delay\":\"" + delay;
} }
if(dimpayload != null) if (dimpayload !== null)
self.state.device.dimUrl = self.state.device.dimUrl + ",\"type\":\"" + deviceMapType + "\"}]"; self.state.device.dimUrl = self.state.device.dimUrl + ",\"type\":\"" + deviceMapType + "\"}]";
self.state.device.onUrl = self.state.device.onUrl + ",\"type\":\"" + deviceMapType + "\"}]"; self.state.device.onUrl = self.state.device.onUrl + ",\"type\":\"" + deviceMapType + "\"}]";
self.state.device.offUrl = self.state.device.offUrl + ",\"type\":\"" + deviceMapType + "\"}]"; self.state.device.offUrl = self.state.device.offUrl + ",\"type\":\"" + deviceMapType + "\"}]";
@@ -762,7 +759,7 @@ app.controller('SystemController', function ($scope, $location, $http, $window,
$scope.visible = false; $scope.visible = false;
$scope.imgUrl = "glyphicon glyphicon-plus"; $scope.imgUrl = "glyphicon glyphicon-plus";
$scope.addVeratoSettings = function (newveraname, newveraip) { $scope.addVeratoSettings = function (newveraname, newveraip) {
if($scope.bridge.settings.veraaddress == null) { if($scope.bridge.settings.veraaddress === null) {
$scope.bridge.settings.veraaddress = { devices: [] }; $scope.bridge.settings.veraaddress = { devices: [] };
} }
var newVera = {name: newveraname, ip: newveraip } var newVera = {name: newveraname, ip: newveraip }
@@ -778,7 +775,7 @@ app.controller('SystemController', function ($scope, $location, $http, $window,
} }
}; };
$scope.addHarmonytoSettings = function (newharmonyname, newharmonyip) { $scope.addHarmonytoSettings = function (newharmonyname, newharmonyip) {
if($scope.bridge.settings.harmonyaddress == null) { if($scope.bridge.settings.harmonyaddress === null) {
$scope.bridge.settings.harmonyaddress = { devices: [] }; $scope.bridge.settings.harmonyaddress = { devices: [] };
} }
var newharmony = {name: newharmonyname, ip: newharmonyip } var newharmony = {name: newharmonyname, ip: newharmonyip }
@@ -794,7 +791,7 @@ app.controller('SystemController', function ($scope, $location, $http, $window,
} }
}; };
$scope.addHuetoSettings = function (newhuename, newhueip) { $scope.addHuetoSettings = function (newhuename, newhueip) {
if($scope.bridge.settings.hueaddress == null) { if($scope.bridge.settings.hueaddress === null) {
$scope.bridge.settings.hueaddress = { devices: [] }; $scope.bridge.settings.hueaddress = { devices: [] };
} }
var newhue = {name: newhuename, ip: newhueip } var newhue = {name: newhuename, ip: newhueip }
@@ -810,7 +807,7 @@ app.controller('SystemController', function ($scope, $location, $http, $window,
} }
}; };
$scope.addHaltoSettings = function (newhalname, newhalip) { $scope.addHaltoSettings = function (newhalname, newhalip) {
if($scope.bridge.settings.haladdress == null) { if($scope.bridge.settings.haladdress === null) {
$scope.bridge.settings.haladdress = { devices: [] }; $scope.bridge.settings.haladdress = { devices: [] };
} }
var newhal = {name: newhalname, ip: newhalip } var newhal = {name: newhalname, ip: newhalip }
@@ -826,7 +823,7 @@ app.controller('SystemController', function ($scope, $location, $http, $window,
} }
}; };
$scope.addMQTTtoSettings = function (newmqttname, newmqttip, newmqttusername, newmqttpassword) { $scope.addMQTTtoSettings = function (newmqttname, newmqttip, newmqttusername, newmqttpassword) {
if($scope.bridge.settings.mqttaddress == null) { if($scope.bridge.settings.mqttaddress === null) {
$scope.bridge.settings.mqttaddress = { devices: [] }; $scope.bridge.settings.mqttaddress = { devices: [] };
} }
var newmqtt = {name: newmqttname, ip: newmqttip, username: newmqttusername, password: newmqttpassword } var newmqtt = {name: newmqttname, ip: newmqttip, username: newmqttusername, password: newmqttpassword }
@@ -844,7 +841,7 @@ app.controller('SystemController', function ($scope, $location, $http, $window,
} }
}; };
$scope.addHasstoSettings = function (newhassname, newhassip, newhassport, newhasspassword) { $scope.addHasstoSettings = function (newhassname, newhassip, newhassport, newhasspassword) {
if($scope.bridge.settings.hassaddress == null) { if($scope.bridge.settings.hassaddress === null) {
$scope.bridge.settings.hassaddress = { devices: [] }; $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 }
@@ -945,13 +942,13 @@ app.controller('ViewingController', function ($scope, $location, $http, $window,
$scope.imgBkUrl = "glyphicon glyphicon-plus"; $scope.imgBkUrl = "glyphicon glyphicon-plus";
$scope.testUrl = function (device, type) { $scope.testUrl = function (device, type) {
var dialogNeeded = false; var dialogNeeded = false;
if((type == "on" && (bridgeService.aContainsB(device.onUrl, "${intensity.byte}") || if((type === "on" && (bridgeService.aContainsB(device.onUrl, "${intensity.byte}") ||
bridgeService.aContainsB(device.onUrl, "${intensity.percent}") || bridgeService.aContainsB(device.onUrl, "${intensity.percent}") ||
bridgeService.aContainsB(device.onUrl, "${intensity.math(")) || bridgeService.aContainsB(device.onUrl, "${intensity.math(")) ||
(type == "off" && (bridgeService.aContainsB(device.offUrl, "${intensity.byte}") || (type === "off" && (bridgeService.aContainsB(device.offUrl, "${intensity.byte}") ||
bridgeService.aContainsB(device.offUrl, "${intensity.percent}") || bridgeService.aContainsB(device.offUrl, "${intensity.percent}") ||
bridgeService.aContainsB(device.offUrl, "${intensity.math("))) || bridgeService.aContainsB(device.offUrl, "${intensity.math("))) ||
(type == "dim"))) { (type === "dim"))) {
$scope.bridge.device = device; $scope.bridge.device = device;
$scope.bridge.type = type; $scope.bridge.type = type;
ngDialog.open({ ngDialog.open({
@@ -1015,7 +1012,7 @@ app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state; $scope.bridge = bridgeService.state;
$scope.valueType = "percentage"; $scope.valueType = "percentage";
$scope.changeScale = function () { $scope.changeScale = function () {
if($scope.valueType == "raw") { if($scope.valueType === "raw") {
$scope.slider.options.ceil = 255; $scope.slider.options.ceil = 255;
$scope.slider.value = 255; $scope.slider.value = 255;
} }
@@ -1027,7 +1024,7 @@ app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
$scope.setValue = function () { $scope.setValue = function () {
ngDialog.close('ngdialog1'); ngDialog.close('ngdialog1');
var theValue = 0; var theValue = 0;
if($scope.valueType == "percentage") if($scope.valueType === "percentage")
theValue = Math.round(($scope.slider.value * .01) * 255); theValue = Math.round(($scope.slider.value * .01) * 255);
else else
theValue = $scope.slider.value; theValue = $scope.slider.value;
@@ -1056,23 +1053,23 @@ app.controller('DeleteMapandIdDialogCtrl', function ($scope, bridgeService, ngDi
ngDialog.close('ngdialog1'); ngDialog.close('ngdialog1');
bridgeService.deleteDeviceByMapId(mapandid.id, mapandid.mapType); bridgeService.deleteDeviceByMapId(mapandid.id, mapandid.mapType);
bridgeService.viewDevices(); bridgeService.viewDevices();
if(mapandid.mapType == "veraDevice") if(mapandid.mapType === "veraDevice")
bridgeService.viewVeraDevices(); bridgeService.viewVeraDevices();
if(mapandid.mapType == "veraScene") if(mapandid.mapType === "veraScene")
bridgeService.viewVeraScenes(); bridgeService.viewVeraScenes();
if(mapandid.mapType == "harmonyActivity") if(mapandid.mapType === "harmonyActivity")
bridgeService.viewHarmonyActivities(); bridgeService.viewHarmonyActivities();
if(mapandid.mapType == "harmonyButton") if(mapandid.mapType === "harmonyButton")
bridgeService.viewHarmonyDevices(); bridgeService.viewHarmonyDevices();
if(mapandid.mapType == "nestThermoSet" || mapandid.mapType == "nestHomeAway") if(mapandid.mapType === "nestThermoSet" || mapandid.mapType === "nestHomeAway")
bridgeService.viewNestItems(); bridgeService.viewNestItems();
if(mapandid.mapType == "hueDevice") if(mapandid.mapType === "hueDevice")
bridgeService.viewHueDevices(); bridgeService.viewHueDevices();
if(mapandid.mapType == "halDevice") if(mapandid.mapType === "halDevice")
bridgeService.viewHalDevices(); bridgeService.viewHalDevices();
if(mapandid.mapType == "mqttMessage") if(mapandid.mapType === "mqttMessage")
bridgeService.viewMQTTDevices(); bridgeService.viewMQTTDevices();
if(mapandid.mapType == "hassDevice") if(mapandid.mapType === "hassDevice")
bridgeService.viewHassDevices(); bridgeService.viewHassDevices();
$scope.bridge.mapandid = null; $scope.bridge.mapandid = null;
}; };
@@ -1128,7 +1125,7 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi
}; };
$scope.addDevice = function () { $scope.addDevice = function () {
if($scope.device.name == "" && $scope.device.onUrl == "") if($scope.device.name === "" && $scope.device.onUrl === "")
return; return;
bridgeService.addDevice($scope.device).then( bridgeService.addDevice($scope.device).then(
function () { function () {
@@ -1148,7 +1145,7 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi
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.veradevices.length; x++) { for(var x = 0; x < bridgeService.state.veradevices.length; x++) {
if(bridgeService.state.veradevices[x].id == $scope.bulk.devices[i]) { if(bridgeService.state.veradevices[x].id === $scope.bulk.devices[i]) {
$scope.buildDeviceUrls(bridgeService.state.veradevices[x],dim_control); $scope.buildDeviceUrls(bridgeService.state.veradevices[x],dim_control);
devicesList[i] = { devicesList[i] = {
name: $scope.device.name, name: $scope.device.name,
@@ -1190,7 +1187,7 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi
// is currently selected // is currently selected
if (idx > -1) { if (idx > -1) {
$scope.bulk.devices.splice(idx, 1); $scope.bulk.devices.splice(idx, 1);
if($scope.bulk.devices.length == 0 && $scope.selectAll) if($scope.bulk.devices.length === 0 && $scope.selectAll)
$scope.selectAll = false; $scope.selectAll = false;
} }
@@ -1263,7 +1260,7 @@ app.controller('HarmonyController', function ($scope, $location, $http, bridgeSe
}; };
$scope.addDevice = function () { $scope.addDevice = function () {
if($scope.device.name == "" && $scope.device.onUrl == "") if($scope.device.name === "" && $scope.device.onUrl === "")
return; return;
bridgeService.addDevice($scope.device).then( bridgeService.addDevice($scope.device).then(
function () { function () {
@@ -1354,7 +1351,7 @@ app.controller('NestController', function ($scope, $location, $http, bridgeServi
}; };
$scope.addDevice = function () { $scope.addDevice = function () {
if($scope.device.name == "" && $scope.device.onUrl == "") if($scope.device.name === "" && $scope.device.onUrl === "")
return; return;
bridgeService.addDevice($scope.device).then( bridgeService.addDevice($scope.device).then(
function () { function () {
@@ -1407,7 +1404,7 @@ app.controller('HueController', function ($scope, $location, $http, bridgeServic
}; };
$scope.addDevice = function () { $scope.addDevice = function () {
if($scope.device.name == "" && $scope.device.onUrl == "") if($scope.device.name === "" && $scope.device.onUrl === "")
return; return;
bridgeService.addDevice($scope.device).then( bridgeService.addDevice($scope.device).then(
function () { function () {
@@ -1426,7 +1423,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].device.uniqueid == $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,
@@ -1468,7 +1465,7 @@ app.controller('HueController', function ($scope, $location, $http, bridgeServic
// is currently selected // is currently selected
if (idx > -1) { if (idx > -1) {
$scope.bulk.devices.splice(idx, 1); $scope.bulk.devices.splice(idx, 1);
if($scope.bulk.devices.length == 0 && $scope.selectAll) if($scope.bulk.devices.length === 0 && $scope.selectAll)
$scope.selectAll = false; $scope.selectAll = false;
} }
@@ -1533,18 +1530,18 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
var nameCmd = ""; var nameCmd = "";
var aDeviceType; var aDeviceType;
var postCmd = "?Token=" + $scope.bridge.settings.haltoken; var postCmd = "?Token=" + $scope.bridge.settings.haltoken;
if(haldevice.haldevicetype == "Group") { if(haldevice.haldevicetype === "Group") {
aDeviceType = "group"; aDeviceType = "group";
preOnCmd = "/GroupService!GroupCmd=On"; preOnCmd = "/GroupService!GroupCmd=On";
preOffCmd = "/GroupService!GroupCmd=Off"; preOffCmd = "/GroupService!GroupCmd=Off";
nameCmd = "!GroupName="; nameCmd = "!GroupName=";
} }
else if(haldevice.haldevicetype == "Macro") { else if(haldevice.haldevicetype === "Macro") {
aDeviceType = "macro"; aDeviceType = "macro";
preOnCmd = "/MacroService!MacroCmd=Set!MacroName="; preOnCmd = "/MacroService!MacroCmd=Set!MacroName=";
preOffCmd = preOnCmd; preOffCmd = preOnCmd;
} }
else if(haldevice.haldevicetype == "Scene") { else if(haldevice.haldevicetype === "Scene") {
aDeviceType = "scene"; aDeviceType = "scene";
preOnCmd = "/SceneService!SceneCmd=Set!SceneName="; preOnCmd = "/SceneService!SceneCmd=Set!SceneName=";
preOffCmd = preOnCmd; preOffCmd = preOnCmd;
@@ -1556,7 +1553,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
preOffCmd = "/DeviceService!DeviceCmd=SetDevice!DeviceValue=Off"; preOffCmd = "/DeviceService!DeviceCmd=SetDevice!DeviceValue=Off";
nameCmd = "!DeviceName="; nameCmd = "!DeviceName=";
} }
if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) && aDeviceType == "switch") if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) && aDeviceType === "switch")
dimpayload = "http://" + haldevice.haladdress dimpayload = "http://" + haldevice.haladdress
+ preDimCmd + preDimCmd
+ dim_control + dim_control
@@ -1677,7 +1674,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
}; };
$scope.addDevice = function () { $scope.addDevice = function () {
if($scope.device.name == "" && $scope.device.onUrl == "") if($scope.device.name === "" && $scope.device.onUrl === "")
return; return;
bridgeService.addDevice($scope.device).then( bridgeService.addDevice($scope.device).then(
function () { function () {
@@ -1696,10 +1693,10 @@ app.controller('HalController', 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.haldevices.length; x++) { for(var x = 0; x < bridgeService.state.haldevices.length; x++) {
if(bridgeService.state.haldevices[x].haldevicename == $scope.bulk.devices[i]) { if(bridgeService.state.haldevices[x].haldevicename === $scope.bulk.devices[i]) {
if(bridgeService.state.haldevices[x].haldevicetype == "HVAC") if(bridgeService.state.haldevices[x].haldevicetype === "HVAC")
$scope.buildHALAutoUrls(bridgeService.state.haldevices[x]); $scope.buildHALAutoUrls(bridgeService.state.haldevices[x]);
else if(bridgeService.state.haldevices[x].haldevicetype == "HOME") else if(bridgeService.state.haldevices[x].haldevicetype === "HOME")
$scope.buildHALHomeUrls(bridgeService.state.haldevices[x]); $scope.buildHALHomeUrls(bridgeService.state.haldevices[x]);
else else
$scope.buildDeviceUrls(bridgeService.state.haldevices[x],dim_control); $scope.buildDeviceUrls(bridgeService.state.haldevices[x],dim_control);
@@ -1742,7 +1739,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
// is currently selected // is currently selected
if (idx > -1) { if (idx > -1) {
$scope.bulk.devices.splice(idx, 1); $scope.bulk.devices.splice(idx, 1);
if($scope.bulk.devices.length == 0 && $scope.selectAll) if($scope.bulk.devices.length === 0 && $scope.selectAll)
$scope.selectAll = false; $scope.selectAll = false;
} }
@@ -1805,7 +1802,7 @@ app.controller('MQTTController', function ($scope, $location, $http, bridgeServi
}; };
$scope.addDevice = function () { $scope.addDevice = function () {
if($scope.device.name == "" && $scope.device.onUrl == "") if($scope.device.name === "" && $scope.device.onUrl === "")
return; return;
bridgeService.addDevice($scope.device).then( bridgeService.addDevice($scope.device).then(
function () { function () {
@@ -1919,7 +1916,7 @@ app.controller('HassController', function ($scope, $location, $http, bridgeServi
}; };
$scope.addDevice = function () { $scope.addDevice = function () {
if($scope.device.name == "" && $scope.device.onUrl == "") if($scope.device.name === "" && $scope.device.onUrl === "")
return; return;
bridgeService.addDevice($scope.device).then( bridgeService.addDevice($scope.device).then(
function () { function () {
@@ -1938,8 +1935,8 @@ app.controller('HassController', function ($scope, $location, $http, bridgeServi
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.hassdevices.length; x++) { for(var x = 0; x < bridgeService.state.hassdevices.length; x++) {
if(bridgeService.state.hassdevices[x].deviceName == $scope.bulk.devices[i]) { if(bridgeService.state.hassdevices[x].deviceName === $scope.bulk.devices[i]) {
if(bridgeService.state.hassdevices[x].domain == "climate") if(bridgeService.state.hassdevices[x].domain === "climate")
$scope.buildHassAutoUrls(bridgeService.state.hassdevices[x]); $scope.buildHassAutoUrls(bridgeService.state.hassdevices[x]);
else else
$scope.buildDeviceUrls(bridgeService.state.hassdevices[x],dim_control); $scope.buildDeviceUrls(bridgeService.state.hassdevices[x],dim_control);
@@ -1982,7 +1979,7 @@ app.controller('HassController', function ($scope, $location, $http, bridgeServi
// is currently selected // is currently selected
if (idx > -1) { if (idx > -1) {
$scope.bulk.devices.splice(idx, 1); $scope.bulk.devices.splice(idx, 1);
if($scope.bulk.devices.length == 0 && $scope.selectAll) if($scope.bulk.devices.length === 0 && $scope.selectAll)
$scope.selectAll = false; $scope.selectAll = false;
} }
@@ -2041,7 +2038,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
}; };
$scope.addDevice = function () { $scope.addDevice = function () {
if($scope.device.name == "" && $scope.device.onUrl == "") if($scope.device.name === "" && $scope.device.onUrl === "")
return; return;
$scope.device.mapType = $scope.mapTypeSelected[0]; $scope.device.mapType = $scope.mapTypeSelected[0];
bridgeService.addDevice($scope.device).then( bridgeService.addDevice($scope.device).then(
@@ -2055,12 +2052,12 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
}; };
$scope.copyDevice = function () { $scope.copyDevice = function () {
if($scope.device.name == "" && $scope.device.onUrl == "") { if($scope.device.name === "" && $scope.device.onUrl === "") {
$scope.clearDevice(); $scope.clearDevice();
return; return;
} }
if($scope.device.name == $scope.bridge.olddevicename) { if($scope.device.name === $scope.bridge.olddevicename) {
$scope.clearDevice(); $scope.clearDevice();
return; return;
} }
@@ -2080,7 +2077,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
app.filter('availableHarmonyActivityId', function(bridgeService) { app.filter('availableHarmonyActivityId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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].activity.id, input[i].hub, "harmonyActivity")){ if(!bridgeService.findDeviceByMapId(input[i].activity.id, input[i].hub, "harmonyActivity")){
@@ -2094,7 +2091,7 @@ app.filter('availableHarmonyActivityId', function(bridgeService) {
app.filter('unavailableHarmonyActivityId', function(bridgeService) { app.filter('unavailableHarmonyActivityId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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].activity.id, input[i].hub, "harmonyActivity")){ if(bridgeService.findDeviceByMapId(input[i].activity.id, input[i].hub, "harmonyActivity")){
@@ -2108,7 +2105,7 @@ app.filter('unavailableHarmonyActivityId', function(bridgeService) {
app.filter('availableVeraDeviceId', function(bridgeService) { app.filter('availableVeraDeviceId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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].id, input[i].veraname, "veraDevice")){ if(!bridgeService.findDeviceByMapId(input[i].id, input[i].veraname, "veraDevice")){
@@ -2122,7 +2119,7 @@ app.filter('availableVeraDeviceId', function(bridgeService) {
app.filter('unavailableVeraDeviceId', function(bridgeService) { app.filter('unavailableVeraDeviceId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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].id, input[i].veraname, "veraDevice")){ if(bridgeService.findDeviceByMapId(input[i].id, input[i].veraname, "veraDevice")){
@@ -2136,7 +2133,7 @@ app.filter('unavailableVeraDeviceId', function(bridgeService) {
app.filter('availableVeraSceneId', function(bridgeService) { app.filter('availableVeraSceneId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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].id, input[i].veraname, "veraScene")){ if(!bridgeService.findDeviceByMapId(input[i].id, input[i].veraname, "veraScene")){
@@ -2150,7 +2147,7 @@ app.filter('availableVeraSceneId', function(bridgeService) {
app.filter('unavailableVeraSceneId', function(bridgeService) { app.filter('unavailableVeraSceneId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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].id,input[i].veraname, "veraScene")){ if(bridgeService.findDeviceByMapId(input[i].id,input[i].veraname, "veraScene")){
@@ -2164,7 +2161,7 @@ app.filter('unavailableVeraSceneId', function(bridgeService) {
app.filter('availableNestItemId', function(bridgeService) { app.filter('availableNestItemId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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.findNestItemByMapId(input[i].id, "nestHomeAway")){ if(!bridgeService.findNestItemByMapId(input[i].id, "nestHomeAway")){
@@ -2178,10 +2175,10 @@ app.filter('availableNestItemId', function(bridgeService) {
app.filter('unavailableNestItemId', function(bridgeService) { app.filter('unavailableNestItemId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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(input[i].mapType != null && bridgeService.aContainsB(input[i].mapType, "nest")){ if(input[i].mapType !== null && bridgeService.aContainsB(input[i].mapType, "nest")){
out.push(input[i]); out.push(input[i]);
} }
} }
@@ -2192,7 +2189,7 @@ app.filter('unavailableNestItemId', function(bridgeService) {
app.filter('availableHueDeviceId', function(bridgeService) { app.filter('availableHueDeviceId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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].device.uniqueid, input[i].huename, "hueDevice")){ if(!bridgeService.findDeviceByMapId(input[i].device.uniqueid, input[i].huename, "hueDevice")){
@@ -2206,7 +2203,7 @@ app.filter('availableHueDeviceId', function(bridgeService) {
app.filter('unavailableHueDeviceId', function(bridgeService) { app.filter('unavailableHueDeviceId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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].device.uniqueid, input[i].huename, "hueDevice")){ if(bridgeService.findDeviceByMapId(input[i].device.uniqueid, input[i].huename, "hueDevice")){
@@ -2220,7 +2217,7 @@ app.filter('unavailableHueDeviceId', function(bridgeService) {
app.filter('availableHalDeviceId', function(bridgeService) { app.filter('availableHalDeviceId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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(!bridgeService.findDeviceByMapId(input[i].haldevicename + "-" + input[i].halname, input[i].halname, "halDevice") &&
@@ -2235,10 +2232,10 @@ app.filter('availableHalDeviceId', function(bridgeService) {
app.filter('unavailableHalDeviceId', function(bridgeService) { app.filter('unavailableHalDeviceId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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(input[i].mapType != null && bridgeService.aContainsB(input[i].mapType, "hal")){ if(input[i].mapType !== null && bridgeService.aContainsB(input[i].mapType, "hal")){
out.push(input[i]); out.push(input[i]);
} }
} }
@@ -2249,10 +2246,10 @@ app.filter('unavailableHalDeviceId', function(bridgeService) {
app.filter('configuredButtons', function() { app.filter('configuredButtons', function() {
return function(input) { return function(input) {
var out = []; var out = [];
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(input[i].mapType == "harmonyButton"){ if(input[i].mapType === "harmonyButton"){
out.push(input[i]); out.push(input[i]);
} }
} }
@@ -2263,10 +2260,10 @@ app.filter('configuredButtons', function() {
app.filter('configuredMqttMsgs', function() { app.filter('configuredMqttMsgs', function() {
return function(input) { return function(input) {
var out = []; var out = [];
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(input[i].mapType == "mqttMessage"){ if(input[i].mapType === "mqttMessage"){
out.push(input[i]); out.push(input[i]);
} }
} }
@@ -2277,7 +2274,7 @@ app.filter('configuredMqttMsgs', function() {
app.filter('availableHassDeviceId', function(bridgeService) { app.filter('availableHassDeviceId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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].hassdevicename + "-" + input[i].hassname, input[i].hassname, "hassDevice")){ if(!bridgeService.findDeviceByMapId(input[i].hassdevicename + "-" + input[i].hassname, input[i].hassname, "hassDevice")){
@@ -2291,10 +2288,10 @@ app.filter('availableHassDeviceId', function(bridgeService) {
app.filter('unavailableHassDeviceId', function(bridgeService) { app.filter('unavailableHassDeviceId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
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(input[i].mapType != null && bridgeService.aContainsB(input[i].mapType, "hass")){ if(input[i].mapType !== null && bridgeService.aContainsB(input[i].mapType, "hass")){
out.push(input[i]); out.push(input[i]);
} }
} }