Initial fixes and cleanup prior to pull request 1

This commit is contained in:
Monica Goward
2017-02-06 21:28:06 +00:00
parent 470f6b3c15
commit f8474f5f41
3 changed files with 28 additions and 45 deletions

View File

@@ -21,9 +21,7 @@ import java.util.HashMap;
* Currently supports 'turn on' for open window, and 'turn off' for close. * Currently supports 'turn on' for open window, and 'turn off' for close.
* *
* Known issues: * Known issues:
* //TODO - Fix bug on UI where bulk update seems to add the single device twice * //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)
* //TODO - Fix bug on UI where already configured devices are not shown as such.
*
* Enhancements: * Enhancements:
* //TODO - support 'dimming' for partial window opening. * //TODO - support 'dimming' for partial window opening.
* *
@@ -77,7 +75,6 @@ public class SomfyHome implements Home {
log.debug("executing HUE api request to change activity to Somfy: " + anItem.getItem().getAsString()); log.debug("executing HUE api request to change activity to Somfy: " + anItem.getItem().getAsString());
String jsonToPost = anItem.getItem().getAsString(); String jsonToPost = anItem.getItem().getAsString();
//RunActivity anActivity = new Gson().fromJson(url, RunActivity.class);
SomfyInfo somfyHandler = getSomfyHandler(device.getTargetDevice()); SomfyInfo somfyHandler = getSomfyHandler(device.getTargetDevice());
if(somfyHandler == null) { if(somfyHandler == null) {
log.warn("Should not get here, no Somfy configured"); log.warn("Should not get here, no Somfy configured");
@@ -88,7 +85,9 @@ public class SomfyHome implements Home {
try { try {
somfyHandler.execApply(jsonToPost); somfyHandler.execApply(jsonToPost);
} catch (Exception e) { } 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 @Override
public void closeHome() { public void closeHome() {
somfys = null;
} }
} }

View File

@@ -2344,6 +2344,7 @@ app.controller('SomfyController', function ($scope, $location, $http, bridgeServ
$scope.bulk = { devices: [] }; $scope.bulk = { devices: [] };
$scope.selectAll = false; $scope.selectAll = false;
$scope.somfy = {base: "http://", port: "3480", id: ""}; $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(); bridgeService.viewSomfyDevices();
$scope.imgButtonsUrl = "glyphicon glyphicon-plus"; $scope.imgButtonsUrl = "glyphicon glyphicon-plus";
$scope.buttonsVisible = false; $scope.buttonsVisible = false;
@@ -2354,8 +2355,8 @@ app.controller('SomfyController', function ($scope, $location, $http, bridgeServ
$scope.device = bridgeService.state.device; $scope.device = bridgeService.state.device;
}; };
$scope.buildDeviceUrls = function (somfydevice, dim_control) { $scope.buildDeviceUrls = function (somfydevice) {
//TODO - support partial window opening //TODO - support partial window opening - add back 'dim_control' second param in here, and in somfydevice.html
dimpayload = ""; dimpayload = "";
onpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"open\",\"parameters\":[]}]}]}"; 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\":[]}]}]}"; 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('configuredSomfyDevices', function (bridgeService) {
app.filter('availableSomfyDeviceId', function(bridgeService) {
return function(input) { return function(input) {
var out = []; var out = [];
if(input == null) if(input === undefined || input === null || input.length === undefined)
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].somfyname, "somfyDevice")){ if(bridgeService.deviceContainsType(input[i], "somfyDevice")){
out.push(input[i]); 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) { app.controller('VersionController', function ($scope, bridgeService) {

View File

@@ -36,20 +36,19 @@
done in the edit tab, click the 'Add Bridge Device' to finish that selection done in the edit tab, click the 'Add Bridge Device' to finish that selection
setup. The 'Already Configured Somfy Devices' list below will show setup. The 'Already Configured Somfy Devices' list below will show
what is already setup for your Somfy.</p> what is already setup for your Somfy.</p>
<p> <!-- TODO - dim support for partial window opening.. --<p>
Also, use this select menu for which type of dim control you would Also, use this select menu for which type of dim control you would
like to be generated: <select name="device-somfy-dim-control" like to be generated: <select name="device-dim-control"
id="device-somfy-dim-control" ng-model="device_somfy_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>
</p> </p-->
<p>Use the check boxes by the names to use the bulk addition <p>Use the check boxes by the names to use the bulk addition
feature. Select your items and dim control type if wanted, then click feature. Select your items, then click
bulk add below. Your items will be added with on and off or dim and bulk add below. Your items will be added with the name of the device from the Somfy Tahoma.</p>
off if selected with the name of the device from the Somfy.</p>
</div> </div>
<scrollable-table watch="bridge.somfydevices"> <scrollable-table watch="bridge.somfydevices">
<table class="table table-bordered table-striped table-hover"> <table class="table table-bordered table-striped table-hover">
@@ -80,15 +79,16 @@
<td>{{somfydevice.room}}</td> <td>{{somfydevice.room}}</td>
<td>{{somfydevice.somfyname}}</td> <td>{{somfydevice.somfyname}}</td>
<td> <td>
<!--TODO - taken device_dim_control out of here since not yet used-->
<button class="btn btn-success" type="submit" <button class="btn btn-success" type="submit"
ng-click="buildDeviceUrls(somfydevice, device_somfy_dim_control)">Build Item</button> ng-click="buildDeviceUrls(somfydevice)">Build Item</button>
</td> </td>
</tr> </tr>
</table> </table>
</scrollable-table> </scrollable-table>
<div class="panel-footer"> <div class="panel-footer">
<button class="btn btn-success" type="submit" <button class="btn btn-success" type="submit"
ng-click="bulkAddDevices(device_somfy_dim_control)">Bulk Add ng-click="bulkAddDevices(device_dim_control)">Bulk Add
({{bulk.devices.length}})</button> ({{bulk.devices.length}})</button>
</div> </div>
</div> </div>
@@ -97,7 +97,7 @@
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title"> <h2 class="panel-title">
Already Configured Somfy Devices <a ng-click="toggleButtons()"><span Already Configured Somfy Devices <a ng-click="toggleButtons()"><span
class={{imgButtonsUrl}} aria-hidden="true"></span></a></a> class={{imgButtonsUrl}} aria-hidden="true"></span></a>
</h2> </h2>
</div> </div>
<div ng-if="buttonsVisible" class="panel-body"> <div ng-if="buttonsVisible" class="panel-body">
@@ -107,10 +107,8 @@
<tr> <tr>
<th>Row</th> <th>Row</th>
<th sortable-header col="name">Name</th> <th sortable-header col="name">Name</th>
<th sortable-header col="id">Id</th> <th sortable-header col="targetDevice">Somfy</th>
<th sortable-header col="category">Category</th> <th>Map Id</th>
<th sortable-header col="room">Room</th>
<th sortable-header col="somfyname">Somfy</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
@@ -118,10 +116,8 @@
ng-repeat="device in bridge.devices |configuredSomfyDevices"> ng-repeat="device in bridge.devices |configuredSomfyDevices">
<td>{{$index+1}}</td> <td>{{$index+1}}</td>
<td>{{device.name}}</td> <td>{{device.name}}</td>
<td>{{device.id}}</td> <td>{{device.targetDevice}}</td>
<td>{{device.category}}</td> <td>{{device.mapId}}</td>
<td>{{device.room}}</td>
<td>{{device.somfyname}}</td>
<td> <td>
<p> <p>
<button class="btn btn-warning" type="submit" <button class="btn btn-warning" type="submit"