Added possibility to refresh individual Zigbee attributes.
This commit is contained in:
parent
7cf6849e5d
commit
95ff5b81c0
2 changed files with 59 additions and 4 deletions
|
|
@ -151,10 +151,11 @@
|
|||
|
||||
<table class="table table-hover table-condensed">
|
||||
<thead>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Last Value</th>
|
||||
<th>Last Report Time</th>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Last Value</th>
|
||||
<th>Last Report Time</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
{{#.getAttributes()}}
|
||||
<tr>
|
||||
|
|
@ -162,6 +163,20 @@
|
|||
<td>{{.getName()}}</td>
|
||||
<td>{{.getLastValue()}}</td>
|
||||
<td><span class="timestamp">{{.getLastReportTime().getTimeInMillis()}}</span></td>
|
||||
<td>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="nodeAddress" value="{{.cluster.zigbeeEndpoint.node.getIeeeAddress()}}">
|
||||
<input type="hidden" name="endpointId" value="{{.cluster.zigbeeEndpoint.getEndpointId()}}">
|
||||
<input type="hidden" name="clusterId" value="{{.cluster.getClusterId()}}">
|
||||
<input type="hidden" name="attributeId" value="{{.getId()}}">
|
||||
|
||||
<div class="btn-toolbar pull-right">
|
||||
<button type="submit" class="btn btn-primary btn-xs" name="action" value="refresh">
|
||||
<span class="glyphicon glyphicon-refresh"></span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{{/.getAttributes()}}
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,17 @@
|
|||
package se.hal.plugin.zigbee.page;
|
||||
|
||||
import com.zsmartsystems.zigbee.IeeeAddress;
|
||||
import com.zsmartsystems.zigbee.ZigBeeEndpoint;
|
||||
import com.zsmartsystems.zigbee.ZigBeeNode;
|
||||
import com.zsmartsystems.zigbee.zcl.ZclAttribute;
|
||||
import com.zsmartsystems.zigbee.zcl.ZclCluster;
|
||||
import se.hal.HalContext;
|
||||
import se.hal.intf.HalAbstractController;
|
||||
import se.hal.intf.HalAbstractControllerManager;
|
||||
import se.hal.intf.HalWebPage;
|
||||
import se.hal.plugin.zigbee.ZigbeeController;
|
||||
import se.hal.struct.Event;
|
||||
import zutil.ObjectUtil;
|
||||
import zutil.io.file.FileUtil;
|
||||
import zutil.parser.Templator;
|
||||
|
||||
|
|
@ -29,6 +35,40 @@ public class ZigbeeNetworkPage extends HalWebPage {
|
|||
|
||||
ZigbeeController controller = HalAbstractControllerManager.getController(ZigbeeController.class);
|
||||
|
||||
if (request.containsKey("action")) {
|
||||
ZigBeeNode node = null;
|
||||
ZigBeeEndpoint endpoint = null;
|
||||
ZclCluster cluster = null;
|
||||
ZclAttribute attribute = null;
|
||||
|
||||
if (!ObjectUtil.isEmpty(request.get("nodeAddress"))) {
|
||||
String nodeAddress = request.get("nodeAddress");
|
||||
node = controller.getNode(new IeeeAddress(nodeAddress));
|
||||
|
||||
if (!ObjectUtil.isEmpty(request.get("endpointId"))) {
|
||||
int endpointId = Integer.parseInt(request.get("endpointId"));
|
||||
endpoint = node.getEndpoint(endpointId);
|
||||
|
||||
if (!ObjectUtil.isEmpty(request.get("clusterId"))) {
|
||||
int clusterId = Integer.parseInt(request.get("clusterId"));
|
||||
cluster = endpoint.getInputCluster(clusterId);
|
||||
|
||||
if (!ObjectUtil.isEmpty(request.get("attributeId"))) {
|
||||
int attributeId = Integer.parseInt(request.get("attributeId"));
|
||||
attribute = cluster.getAttribute(attributeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (request.get("action")) {
|
||||
case "refresh":
|
||||
if (attribute != null)
|
||||
attribute.readValue(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
|
||||
tmpl.set("controller", controller);
|
||||
tmpl.set("nodes", controller.getNodes());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue