From 315fd312706fe97b73a1df9f9173788a52833353 Mon Sep 17 00:00:00 2001
From: Admin
Date: Mon, 25 Jan 2016 16:35:22 -0600
Subject: [PATCH] implemented multi button build for devices. more testing
needed. fixed tab display on first view.
---
pom.xml | 2 +-
.../bwssystems/HABridge/hue/HueMulator.java | 17 +++-
src/main/resources/public/scripts/app.js | 89 ++++++++-----------
.../resources/public/views/editdevice.html | 6 +-
src/main/resources/public/views/editor.html | 6 +-
.../public/views/harmonyactivity.html | 10 ++-
.../resources/public/views/harmonydevice.html | 13 +--
.../resources/public/views/nestactions.html | 10 ++-
.../resources/public/views/veradevice.html | 10 ++-
.../resources/public/views/verascene.html | 10 ++-
10 files changed, 93 insertions(+), 80 deletions(-)
diff --git a/pom.xml b/pom.xml
index 85fe04d..52171e7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.bwssystems.HABridge
ha-bridge
- 1.3.1
+ 1.3.1a
jar
HA Bridge
diff --git a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
index a0f7725..965d00b 100644
--- a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
+++ b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
@@ -334,16 +334,25 @@ public class HueMulator {
}
else if(device.getDeviceType().toLowerCase().contains("button") || (device.getMapType() != null && device.getMapType().equalsIgnoreCase("harmonyButton")))
{
- log.debug("executing HUE api request to button press to Harmony: " + url);
- ButtonPress aDeviceButton = new Gson().fromJson(url, ButtonPress.class);
+ log.debug("executing HUE api request to button press(es) to Harmony: " + url);
+ if(url.substring(0, 1).equalsIgnoreCase("{")) {
+ url = "[" + url +"]";
+ }
+ ButtonPress[] deviceButtons = new Gson().fromJson(url, ButtonPress[].class);
HarmonyHandler myHarmony = myHarmonyHome.getHarmonyHandler(device.getTargetDevice());
if(myHarmony == null)
{
log.warn("Should not get here, no harmony hub available");
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + ",\"description\": \"Should not get here, no harmony hub available\", \"parameter\": \"/lights/" + lightId + "state\"}}]";
}
- else
- myHarmony.pressButton(aDeviceButton);
+ else {
+ for(int i = 0; i < deviceButtons.length; i++) {
+ if( i > 0)
+ Thread.sleep(500);
+ log.debug("pressing button: " + deviceButtons[i].getDevice() + " - " + deviceButtons[i].getButton() + " - iteration: " + String.valueOf(i));
+ myHarmony.pressButton(deviceButtons[i]);
+ }
+ }
}
else if(device.getDeviceType().toLowerCase().contains("home") || (device.getMapType() != null && device.getMapType().equalsIgnoreCase("nestHomeAway")))
{
diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js
index ed58e32..e774eda 100644
--- a/src/main/resources/public/scripts/app.js
+++ b/src/main/resources/public/scripts/app.js
@@ -35,9 +35,6 @@ app.config(function ($routeProvider) {
app.run( function (bridgeService) {
bridgeService.loadBridgeSettings();
- bridgeService.updateShowVera();
- bridgeService.updateShowHarmony();
- bridgeService.updateShowNest();
bridgeService.getHABridgeVersion();
});
@@ -180,6 +177,9 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) {
self.BridgeSettings.setupnpstrict(response.data.upnpstrict);
self.BridgeSettings.setdevmode(response.data.devmode);
self.BridgeSettings.setnestconfigured(response.data.nestconfigured);
+ self.updateShowVera();
+ self.updateShowHarmony();
+ self.updateShowNest();
},
function (error) {
if (error.data) {
@@ -418,9 +418,6 @@ app.controller('ViewingController', function ($scope, $location, $http, $window,
$scope.BridgeSettings = bridgeService.BridgeSettings;
bridgeService.viewDevices();
$scope.bridge = bridgeService.state;
- bridgeService.updateShowVera();
- bridgeService.updateShowHarmony();
- bridgeService.updateShowNest();
$scope.visible = false;
$scope.imgUrl = "glyphicon glyphicon-plus";
$scope.predicate = '';
@@ -456,29 +453,36 @@ app.controller('ViewingController', function ($scope, $location, $http, $window,
});
app.controller('AddingController', function ($scope, $location, $http, bridgeService, BridgeSettings) {
+ $scope.device = {id: "", name: "", deviceType: "custom", onUrl: "", offUrl: ""};
+ $scope.clearDevice = function () {
+ $scope.device.id = "";
+ $scope.device.mapType = null;
+ $scope.device.mapId = null;
+ $scope.device.name = "";
+ $scope.device.onUrl = "";
+ $scope.device.deviceType = "custom";
+ $scope.device.targetDevice = null;
+ $scope.device.offUrl = "";
+ $scope.device.httpVerb = null;
+ $scope.device.contentType = null;
+ $scope.device.contentBody = null;
+ $scope.device.contentBodyOff = null;
+ };
- $scope.device = {id: "", name: "", deviceType: "custom", onUrl: "", offUrl: ""};
+
+ $scope.clearDevice();
+ bridgeService.device = $scope.device;
$scope.vera = {base: "", port: "3480", id: ""};
$scope.vera.base = "http://" + BridgeSettings.veraaddress;
- bridgeService.device = $scope.device;
bridgeService.viewVeraDevices();
bridgeService.viewVeraScenes();
bridgeService.viewHarmonyActivities();
bridgeService.viewHarmonyDevices();
bridgeService.viewNestItems();
$scope.bridge = bridgeService.state;
- bridgeService.updateShowVera();
- bridgeService.updateShowHarmony();
- bridgeService.updateShowNest();
$scope.device = bridgeService.state.device;
- $scope.activitiesVisible = false;
$scope.imgButtonsUrl = "glyphicon glyphicon-plus";
$scope.buttonsVisible = false;
- $scope.imgActivitiesUrl = "glyphicon glyphicon-plus";
- $scope.devicesVisible = false;
- $scope.imgDevicesUrl = "glyphicon glyphicon-plus";
- $scope.scenesVisible = false;
- $scope.imgScenesUrl = "glyphicon glyphicon-plus";
$scope.predicate = '';
$scope.reverse = true;
$scope.device_dim_control = "";
@@ -574,13 +578,21 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
};
$scope.buildButtonUrls = function (harmonydevice, onbutton, offbutton) {
- $scope.device.deviceType = "button";
- $scope.device.targetDevice = harmonydevice.hub;
- $scope.device.name = harmonydevice.device.label;
- $scope.device.mapType = "harmonyButton";
- $scope.device.mapId = harmonydevice.device.id + "-" + onbutton + "-" + offbutton;
- $scope.device.onUrl = "{\"device\":\"" + harmonydevice.device.id + "\",\"button\":\"" + onbutton + "\"}";
- $scope.device.offUrl = "{\"device\":\"" + harmonydevice.device.id + "\",\"button\":\"" + offbutton + "\"}";
+ var currentOn = $scope.device.onUrl;
+ var currentOff = $scope.device.offUrl;
+ if( $scope.device.mapType == "harmonyButton") {
+ $scope.device.onUrl = currentOn.substr(0, currentOn.indexOf("]")) + ",{\"device\":\"" + harmonydevice.device.id + "\",\"button\":\"" + onbutton + "\"}]";
+ $scope.device.offUrl = currentOff.substr(0, currentOff.indexOf("]")) + ",{\"device\":\"" + harmonydevice.device.id + "\",\"button\":\"" + offbutton + "\"}]";
+ }
+ else if ($scope.device.mapType == null || $scope.device.mapType == "") {
+ $scope.device.deviceType = "button";
+ $scope.device.targetDevice = harmonydevice.hub;
+ $scope.device.name = harmonydevice.device.label;
+ $scope.device.mapType = "harmonyButton";
+ $scope.device.mapId = harmonydevice.device.id + "-" + onbutton + "-" + offbutton;
+ $scope.device.onUrl = "[{\"device\":\"" + harmonydevice.device.id + "\",\"button\":\"" + onbutton + "\"}]";
+ $scope.device.offUrl = "[{\"device\":\"" + harmonydevice.device.id + "\",\"button\":\"" + offbutton + "\"}]";
+ }
};
$scope.buildNestHomeUrls = function (nestitem) {
@@ -651,6 +663,8 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
};
$scope.addDevice = function () {
+ if($scope.device.name == "" && $scope.device.onUrl == "")
+ return;
bridgeService.addDevice($scope.device).then(
function () {
$scope.device.id = "";
@@ -665,21 +679,12 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
$scope.device.contentType = null;
$scope.device.contentBody = null;
$scope.device.contentBodyOff = null;
- $location.path('/#');
},
function (error) {
}
);
}
- $scope.toggleActivities = function () {
- $scope.activitiesVisible = !$scope.activitiesVisible;
- if($scope.activitiesVisible)
- $scope.imgActivitiesUrl = "glyphicon glyphicon-minus";
- else
- $scope.imgActivitiesUrl = "glyphicon glyphicon-plus";
- };
-
$scope.toggleButtons = function () {
$scope.buttonsVisible = !$scope.buttonsVisible;
if($scope.buttonsVisible)
@@ -687,23 +692,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
else
$scope.imgButtonsUrl = "glyphicon glyphicon-plus";
};
-
- $scope.toggleDevices = function () {
- $scope.devicesVisible = !$scope.devicesVisible;
- if($scope.devicesVisible)
- $scope.imgDevicesUrl = "glyphicon glyphicon-minus";
- else
- $scope.imgDevicesUrl = "glyphicon glyphicon-plus";
- };
-
- $scope.toggleScenes = function () {
- $scope.scenesVisible = !$scope.scenesVisible;
- if($scope.scenesVisible)
- $scope.imgScenesUrl = "glyphicon glyphicon-minus";
- else
- $scope.imgScenesUrl = "glyphicon glyphicon-plus";
- };
-
+
$scope.deleteDeviceByMapId = function (id, mapType) {
bridgeService.deleteDeviceByMapId(id, mapType);
};
diff --git a/src/main/resources/public/views/editdevice.html b/src/main/resources/public/views/editdevice.html
index 4b47546..b7bd74c 100644
--- a/src/main/resources/public/views/editdevice.html
+++ b/src/main/resources/public/views/editdevice.html
@@ -17,7 +17,7 @@
updating these fields as you may break the settings used by the bridge to call a specific end point device.