Fixed requester filter for multiple echos. Started MQTT MEssage screen.

This commit is contained in:
Admin
2016-11-14 16:43:33 -06:00
parent 3eba9b9245
commit 90f2bce282
4 changed files with 162 additions and 9 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>3.2.2b</version> <version>3.2.2c</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>HA Bridge</name> <name>HA Bridge</name>

View File

@@ -101,13 +101,15 @@ public class DeviceRepository extends BackupHandler {
theDevice = anIterator.next(); theDevice = anIterator.next();
theRequesterAddress = theDevice.getRequesterAddress(); theRequesterAddress = theDevice.getRequesterAddress();
addressMap = new HashMap<String, String>(); addressMap = new HashMap<String, String>();
if (theRequesterAddress.contains(",")) { if(theRequesterAddress != null) {
String[] theArray = theRequesterAddress.split(","); if (theRequesterAddress.contains(",")) {
for (String v : theArray) { String[] theArray = theRequesterAddress.split(",");
addressMap.put(v, v); for (String v : theArray) {
} addressMap.put(v.trim(), v.trim());
} else }
addressMap.put(theRequesterAddress, theRequesterAddress); } else
addressMap.put(theRequesterAddress, theRequesterAddress);
}
if (theRequesterAddress == null || theRequesterAddress.length() == 0 || addressMap.containsKey(anAddress)) if (theRequesterAddress == null || theRequesterAddress.length() == 0 || addressMap.containsKey(anAddress))
theReturnList.add(theDevice); theReturnList.add(theDevice);
} }

View File

@@ -31,7 +31,7 @@ public class MQTTHome {
public void shutdownMQTTClients() { public void shutdownMQTTClients() {
log.debug("Shutting down MQTT handlers."); log.debug("Shutting down MQTT handlers.");
if(!handlers.isEmpty()) { if(handlers != null && !handlers.isEmpty()) {
Iterator<String> keys = handlers.keySet().iterator(); Iterator<String> keys = handlers.keySet().iterator();
while(keys.hasNext()) { while(keys.hasNext()) {
String key = keys.next(); String key = keys.next();

View File

@@ -0,0 +1,151 @@
<ul class="nav nav-pills" role="tablist">
<li role="presentation"><a href="#">Bridge Devices</a></li>
<li role="presentation"><a href="#/system">Bridge Control</a></li>
<li role="presentation"><a href="#/logs">Logs</a></li>
<li ng-if="bridge.showVera" role="presentation"><a href="#/veradevices">Vera Devices</a></li>
<li ng-if="bridge.showVera" role="presentation"><a href="#/verascenes">Vera Scenes</a></li>
<li ng-if="bridge.showHarmony" role="presentation"><a href="#/harmonyactivities">Harmony Activities</a></li>
<li ng-if="bridge.showHarmony" role="presentation"><a href="#/harmonydevices">Harmony Devices</a></li>
<li ng-if="bridge.showNest" role="presentation"><a href="#/nest">Nest</a></li>
<li ng-if="bridge.showHue" role="presentation"><a href="#/huedevices">Hue Devices</a></li>
<li ng-if="bridge.showHal" role="presentation"><a href="#/haldevices">HAL Devices</a></li>
<li role="presentation" class="active"><a href="#/mqttmessages">MQTT Messages</a></li>
<li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">MQTT Messages</h2>
</div>
<div class="panel-body">
<p class="text-muted">For any MQTT Broker, use the
build button to generate the configuration for the publish generation.
You can add topic and content in the text areas provided
then selecting the publish generation. Then you can modify the name
to anything you want that will be the keyword for Alexa. Click the
'Add Bridge Device' to finish that selection setup. The 'Already
Configured MQTT Publish messages' list below will show what is already
setup for your MQTT Brokers.</p>
</div>
<scrollable-table watch="bridge.mqtt">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Row</th>
<th sortable-header col="name">ClientID</th>
<th sortable-header col="ip">IP</th>
<th>Topic</th>
<th>Content</th>
<th>Actions</th>
</tr>
</thead>
<tr ng-repeat="harmonydevice in bridge.harmonydevices">
<td>{{$index+1}}</td>
<td>{{mqtt.broker.name}}</td>
<td>{{mqtt.broker.ip}}</td>
<td>
<textarea rows="3" class="form-control" id="mqtt-topic"
ng-model="mqtttopic" placeholder="URL to turn device on"></textarea>
</td>
<td><
<textarea rows="3" class="form-control" id="mqtt-content"
ng-model="mqttcontent" placeholder="URL to turn device on"></textarea>
</td>
<td>
<button class="btn btn-success" type="submit"
ng-click="buildMQTTPublish(mqtt.broker, dmqtttopic, mqttcontent)">Build
publish Message</button>
</td>
</tr>
</table>
</scrollable-table>
</li>
</ul>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
Already Configured MQTT Messages <a ng-click="toggleButtons()"><span
class={{imgButtonsUrl}} aria-hidden="true"></span></a>
</h2>
</div>
<scrollable-table ng-if="buttonsVisible" watch="bridge.mqtt">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Row</th>
<th sortable-header col="nameclientid">Name</th>
<th sortable-header col="ip">ClientID</th>
<th>MQTT Message ID</th>
<th>Actions</th>
</tr>
</thead>
<tr
ng-repeat="device in bridge.devices | configuredButtons | orderBy:predicate:reverse">
<td>{{$index+1}}</td>
<td>{{device.name}}</td>
<td>{{device.targetDevice}}</td>
<td>{{device.mapId}}</td>
<td>
<button class="btn btn-danger" type="submit"
ng-click="deleteDeviceByMapId(device.mapId, device.mapType)">Delete</button>
</td>
</tr>
</table>
</scrollable-table>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">Add a Bridge Device for MQTT Messages</h2>
</div>
<div class="panel-body">
<form class="form-horizontal">
<div class="form-group">
<label class="col-xs-12 col-sm-2 control-label" for="device-name">Name
</label>
<div class="col-xs-8 col-sm-7">
<input type="text" class="form-control" id="device-name"
ng-model="device.name" placeholder="Device Name">
</div>
<button type="submit" class="col-xs-4 col-sm-2 btn btn-primary"
ng-click="addDevice()">Add Bridge Device</button>
</div>
<div class="form-group">
<div class="row">
<label class="col-xs-12 col-sm-2 control-label" for="device-on-url">On
URL </label>
<div class="col-xs-8 col-sm-7">
<textarea rows="3" class="form-control" id="device-on-url"
ng-model="device.onUrl" placeholder="URL to turn device on"></textarea>
</div>
<button class="btn btn-danger" ng-click="clearDevice()">
Clear Device</button>
</div>
</div>
<div class="form-group">
<div class="row">
<label class="col-xs-12 col-sm-2 control-label"
for="device-off-url">Off URL </label>
<div class="col-xs-8 col-sm-7">
<textarea rows="3" class="form-control" id="device-off-url"
ng-model="device.offUrl" placeholder="URL to turn device off"></textarea>
</div>
</div>
</div>
</form>
</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>