diff --git a/hal-core/resource/resource/web/event_detail.tmpl b/hal-core/resource/resource/web/event_detail.tmpl index 7f875bc4..59e65d55 100644 --- a/hal-core/resource/resource/web/event_detail.tmpl +++ b/hal-core/resource/resource/web/event_detail.tmpl @@ -1,4 +1,4 @@ -

Details for {{event.getName()}}

+

Details for {{event.getName()}}

diff --git a/hal-core/resource/resource/web/sensor_detail.tmpl b/hal-core/resource/resource/web/sensor_detail.tmpl index 92831476..57fafc5f 100644 --- a/hal-core/resource/resource/web/sensor_detail.tmpl +++ b/hal-core/resource/resource/web/sensor_detail.tmpl @@ -1,4 +1,4 @@ -

Details for {{sensor.getName()}}

+

Details for {{sensor.getName()}}

diff --git a/hal-core/src/se/hal/EventControllerManager.java b/hal-core/src/se/hal/EventControllerManager.java index 5bc46a4c..35e9581d 100644 --- a/hal-core/src/se/hal/EventControllerManager.java +++ b/hal-core/src/se/hal/EventControllerManager.java @@ -132,7 +132,7 @@ public class EventControllerManager extends HalAbstractControllerManager) method.invoke(cluster, command)).get(); if (result.isError() || result.isTimeout()) { logger.warning("[Node: " + getZigbeeNodeAddress() + ", Endpoint: " + cluster.getZigBeeAddress() + "] Command failed with error: " + result.isError() + " (timeout=" + result.isTimeout() + ")"); @@ -47,7 +54,7 @@ public abstract class ZigbeeHalEventDeviceConfig extends ZigbeeHalDeviceConfig { logger.info("[Node: " + getZigbeeNodeAddress() + ", Endpoint: " + cluster.getZigBeeAddress() + "] Command has been successfully sent."); } } catch (Exception e) { - logger.warning("[Node: " + getZigbeeNodeAddress() + ", Endpoint: " + cluster.getZigBeeAddress() + "] Failed to send command: " + e.getMessage()); + logger.log(Level.WARNING, "[Node: " + getZigbeeNodeAddress() + ", Endpoint: " + cluster.getZigBeeAddress() + "] Failed to send command.", e); } } else { logger.warning("[Node: " + getZigbeeNodeAddress() + "] Unable to find cluster: " + getZigbeeClusterId()); diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHumidityConfig.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHumidityConfig.java index 3aaf1a96..40b40599 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHumidityConfig.java +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHumidityConfig.java @@ -18,7 +18,11 @@ public class ZigbeeHumidityConfig extends ZigbeeHalDeviceConfig implements HalSe @Override public HalDeviceData getDeviceData(ZclAttribute zclAttribute) { - return new HumiditySensorData(((int) zclAttribute.getLastValue()) / 100.0, zclAttribute.getLastReportTime().getTimeInMillis()); + if (zclAttribute.getId() == ZclRelativeHumidityMeasurementCluster.ATTR_MEASUREDVALUE) + return new HumiditySensorData( + ((int) zclAttribute.getLastValue()) / 100.0, + zclAttribute.getLastReportTime().getTimeInMillis()); + return null; } @Override diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeOnOffConfig.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeOnOffConfig.java index faff06c1..091e6ce8 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeOnOffConfig.java +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeOnOffConfig.java @@ -1,6 +1,5 @@ package se.hal.plugin.zigbee.device; -import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.ZclAttribute; import com.zsmartsystems.zigbee.zcl.ZclCluster; import com.zsmartsystems.zigbee.zcl.ZclCommand; @@ -11,18 +10,41 @@ import se.hal.intf.HalDeviceData; import se.hal.intf.HalEventConfig; import se.hal.intf.HalEventData; import se.hal.struct.devicedata.OnOffEventData; +import zutil.log.LogUtil; + +import java.util.logging.Level; +import java.util.logging.Logger; /** * A device configuration for a specific endpoint on a Zigbee device. */ public class ZigbeeOnOffConfig extends ZigbeeHalEventDeviceConfig implements HalEventConfig { + private static final Logger logger = LogUtil.getLogger(); // -------------------------- // Zigbee Methods // -------------------------- + @Override + public void initialize(ZclCluster cluster) { + if (! (cluster instanceof ZclOnOffCluster)) + return; + + try { + ZclAttribute attribute = cluster.getAttribute(ZclOnOffCluster.ATTR_ONOFF); + attribute.setReporting(1, 900).get(); + attribute.readValue(60); + } catch (Exception e) { + logger.log(Level.WARNING, "Was unable to initialize cluster reporting rate.", e); + } + } + @Override public HalDeviceData getDeviceData(ZclAttribute zclAttribute) { + if (zclAttribute.getId() == ZclOnOffCluster.ATTR_ONOFF) + return new OnOffEventData( + (boolean) zclAttribute.getLastValue(), + zclAttribute.getLastReportTime().getTimeInMillis()); return null; } diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeePressureConfig.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeePressureConfig.java index bb583fb5..08ce3d6c 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeePressureConfig.java +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeePressureConfig.java @@ -19,7 +19,11 @@ public class ZigbeePressureConfig extends ZigbeeHalDeviceConfig implements HalSe @Override public HalDeviceData getDeviceData(ZclAttribute zclAttribute) { - return new PressureSensorData(((int) zclAttribute.getLastValue()), zclAttribute.getLastReportTime().getTimeInMillis()); + if (zclAttribute.getId() == ZclTemperatureMeasurementCluster.ATTR_MAXMEASUREDVALUE) + return new PressureSensorData( + (int) zclAttribute.getLastValue(), + zclAttribute.getLastReportTime().getTimeInMillis()); + return null; } @Override diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeTemperatureConfig.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeTemperatureConfig.java index ccdaee2e..9db529bb 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeTemperatureConfig.java +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeTemperatureConfig.java @@ -18,7 +18,11 @@ public class ZigbeeTemperatureConfig extends ZigbeeHalDeviceConfig implements Ha @Override public HalDeviceData getDeviceData(ZclAttribute zclAttribute) { - return new TemperatureSensorData(((int) zclAttribute.getLastValue()) / 100.0, zclAttribute.getLastReportTime().getTimeInMillis()); + if (zclAttribute.getId() == ZclTemperatureMeasurementCluster.ATTR_MEASUREDVALUE) + return new TemperatureSensorData( + ((int) zclAttribute.getLastValue()) / 100.0, + zclAttribute.getLastReportTime().getTimeInMillis()); + return null; } @Override diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/page/ZigbeeNodeOverviewPage.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/page/ZigbeeNodeOverviewPage.java index 16494dcf..a0deffd1 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/page/ZigbeeNodeOverviewPage.java +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/page/ZigbeeNodeOverviewPage.java @@ -27,16 +27,17 @@ public class ZigbeeNodeOverviewPage extends HalWebPage { Map request) throws Exception { - Set nodes = null; - for (HalAbstractController controller : HalAbstractControllerManager.getControllers()) { - if (controller instanceof ZigbeeController) { - nodes = ((ZigbeeController) controller).getNodes(); + ZigbeeController controller = null; + for (HalAbstractController cont : HalAbstractControllerManager.getControllers()) { + if (cont instanceof ZigbeeController) { + controller = ((ZigbeeController) cont); break; } } Templator tmpl = new Templator(FileUtil.find(TEMPLATE)); - tmpl.set("nodes", nodes); + tmpl.set("controller", controller); + tmpl.set("nodes", controller.getNodes()); return tmpl; } }