diff --git a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java index acbdf89..bdab8a3 100644 --- a/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java +++ b/src/main/java/com/bwssystems/HABridge/plugins/somfy/SomfyHome.java @@ -21,9 +21,7 @@ import java.util.HashMap; * Currently supports 'turn on' for open window, and 'turn off' for close. * * Known issues: - * //TODO - Fix bug on UI where bulk update seems to add the single device twice - * //TODO - Fix bug on UI where already configured devices are not shown as such. - * + * //TODO - Fix bug on UI where bulk update seems to add the single device twice if 'update' is clicked (this is a general bug with Vera too I think) * Enhancements: * //TODO - support 'dimming' for partial window opening. * @@ -76,8 +74,7 @@ public class SomfyHome implements Home { log.debug("executing HUE api request to change activity to Somfy: " + anItem.getItem().getAsString()); String jsonToPost = anItem.getItem().getAsString(); - - //RunActivity anActivity = new Gson().fromJson(url, RunActivity.class); + SomfyInfo somfyHandler = getSomfyHandler(device.getTargetDevice()); if(somfyHandler == null) { log.warn("Should not get here, no Somfy configured"); @@ -88,7 +85,9 @@ public class SomfyHome implements Home { try { somfyHandler.execApply(jsonToPost); } catch (Exception e) { - throw new RuntimeException(e); + log.warn("Error posting request to Somfy"); + responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + + "\",\"description\": \"Error posting request to SomfyTahoma\", \"parameter\": \"/lights/" + lightId + "state\"}}]"; } } @@ -114,6 +113,6 @@ public class SomfyHome implements Home { @Override public void closeHome() { - + somfys = null; } } diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js index 4d28bf5..cbad3e0 100644 --- a/src/main/resources/public/scripts/app.js +++ b/src/main/resources/public/scripts/app.js @@ -2344,6 +2344,7 @@ app.controller('SomfyController', function ($scope, $location, $http, bridgeServ $scope.bulk = { devices: [] }; $scope.selectAll = false; $scope.somfy = {base: "http://", port: "3480", id: ""}; + bridgeService.viewDevices(); //Needs this if you're navigating to the 'somfy' page directly without going to the home page first.. bridgeService.viewSomfyDevices(); $scope.imgButtonsUrl = "glyphicon glyphicon-plus"; $scope.buttonsVisible = false; @@ -2354,8 +2355,8 @@ app.controller('SomfyController', function ($scope, $location, $http, bridgeServ $scope.device = bridgeService.state.device; }; - $scope.buildDeviceUrls = function (somfydevice, dim_control) { - //TODO - support partial window opening + $scope.buildDeviceUrls = function (somfydevice) { + //TODO - support partial window opening - add back 'dim_control' second param in here, and in somfydevice.html dimpayload = ""; onpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"open\",\"parameters\":[]}]}]}"; offpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"close\",\"parameters\":[]}]}]}"; @@ -2732,14 +2733,13 @@ app.filter('configuredDomoticzItems', function (bridgeService) { } }); - -app.filter('availableSomfyDeviceId', function(bridgeService) { +app.filter('configuredSomfyDevices', function (bridgeService) { return function(input) { var out = []; - if(input == null) + if(input === undefined || input === null || input.length === undefined) return out; for (var i = 0; i < input.length; i++) { - if(!bridgeService.findDeviceByMapId(input[i].id, input[i].somfyname, "somfyDevice")){ + if(bridgeService.deviceContainsType(input[i], "somfyDevice")){ out.push(input[i]); } } @@ -2747,19 +2747,7 @@ app.filter('availableSomfyDeviceId', function(bridgeService) { } }); -app.filter('unavailableSomfyDeviceId', function(bridgeService) { - return function(input) { - var out = []; - if(input == null) - return out; - for (var i = 0; i < input.length; i++) { - if(bridgeService.findDeviceByMapId(input[i].id, input[i].somfyname, "somfyDevice")){ - out.push(input[i]); - } - } - return out; - } -}); + app.controller('VersionController', function ($scope, bridgeService) { diff --git a/src/main/resources/public/views/somfydevice.html b/src/main/resources/public/views/somfydevice.html index bae9cd7..7bdbc07 100644 --- a/src/main/resources/public/views/somfydevice.html +++ b/src/main/resources/public/views/somfydevice.html @@ -36,20 +36,19 @@ done in the edit tab, click the 'Add Bridge Device' to finish that selection setup. The 'Already Configured Somfy Devices' list below will show what is already setup for your Somfy.

-

+

Use the check boxes by the names to use the bulk addition - feature. Select your items and dim control type if wanted, then click - bulk add below. Your items will be added with on and off or dim and - off if selected with the name of the device from the Somfy.

+ feature. Select your items, then click + bulk add below. Your items will be added with the name of the device from the Somfy Tahoma.

@@ -80,15 +79,16 @@
{{somfydevice.room}} {{somfydevice.somfyname}} + + ng-click="buildDeviceUrls(somfydevice)">Build Item
@@ -97,7 +97,7 @@

Already Configured Somfy Devices + class={{imgButtonsUrl}} aria-hidden="true">

@@ -107,10 +107,8 @@ Row Name - Id - Category - Room - Somfy + Somfy + Map Id Actions @@ -118,10 +116,8 @@ ng-repeat="device in bridge.devices |configuredSomfyDevices"> {{$index+1}} {{device.name}} - {{device.id}} - {{device.category}} - {{device.room}} - {{device.somfyname}} + {{device.targetDevice}} + {{device.mapId}}

- \ No newline at end of file +