From 95ff5b81c07bd3eb4ed7a4a1948f43d9daf2f02c Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Mon, 23 May 2022 23:19:21 +0200 Subject: [PATCH] Added possibility to refresh individual Zigbee attributes. --- .../resource/resource/web/zigbee_network.tmpl | 23 +++++++++-- .../plugin/zigbee/page/ZigbeeNetworkPage.java | 40 +++++++++++++++++++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/plugins/hal-zigbee/resource/resource/web/zigbee_network.tmpl b/plugins/hal-zigbee/resource/resource/web/zigbee_network.tmpl index 51cb5dd3..0d498da1 100644 --- a/plugins/hal-zigbee/resource/resource/web/zigbee_network.tmpl +++ b/plugins/hal-zigbee/resource/resource/web/zigbee_network.tmpl @@ -151,10 +151,11 @@ - - - - + + + + + {{#.getAttributes()}} @@ -162,6 +163,20 @@ + {{/.getAttributes()}}
IDNameLast ValueLast Report TimeIDNameLast ValueLast Report Time
{{.getName()}} {{.getLastValue()}} {{.getLastReportTime().getTimeInMillis()}} +
+ + + + + +
+ +
+
+
diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/page/ZigbeeNetworkPage.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/page/ZigbeeNetworkPage.java index 72e70ee4..695efbca 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/page/ZigbeeNetworkPage.java +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/page/ZigbeeNetworkPage.java @@ -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());