From 3edea58f8ccd8217754e79587a0f82b59819fd1b Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Sat, 2 Oct 2021 19:42:23 +0200 Subject: [PATCH] Renamed some DeviceData classes, added additional data classes also and better handling in zigbee --- hal-core/src/se/hal/intf/HalEventConfig.java | 6 ++ .../src/se/hal/page/EventOverviewWebPage.java | 4 +- ...orData.java => IlluminanceSensorData.java} | 15 ++-- .../struct/devicedata/OccupancyEventData.java | 74 +++++++++++++++++++ .../hal/struct/devicedata/OnOffEventData.java | 8 +- .../devicedata/OpenClosedEventData.java | 8 +- .../assistant/google/trait/OnOffTrait.java | 5 +- .../plugin/tellstick/device/Oregon0x1A2D.java | 4 +- .../protocol/Oregon0x1A2DProtocol.java | 4 +- .../TelstickSerialCommNexaOnOffTest.java | 4 +- .../resource/resource/web/zigbee_network.tmpl | 16 +++- .../hal/plugin/zigbee/ZigbeeController.java | 16 +--- .../zigbee/device/ZigbeeHalDeviceFactory.java | 40 ++++++++++ .../device/ZigbeeHalEventDeviceConfig.java | 4 +- .../device/ZigbeeIlluminanceConfig.java | 46 ++++++++++++ .../zigbee/device/ZigbeeOccupancyConfig.java | 62 ++++++++++++++++ .../zigbee/device/ZigbeePressureConfig.java | 2 +- .../src/se/hal/plugin/zigbee/plugin.json | 2 + 18 files changed, 275 insertions(+), 45 deletions(-) rename hal-core/src/se/hal/struct/devicedata/{LightSensorData.java => IlluminanceSensorData.java} (62%) create mode 100644 hal-core/src/se/hal/struct/devicedata/OccupancyEventData.java create mode 100644 plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHalDeviceFactory.java create mode 100644 plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeIlluminanceConfig.java create mode 100644 plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeOccupancyConfig.java diff --git a/hal-core/src/se/hal/intf/HalEventConfig.java b/hal-core/src/se/hal/intf/HalEventConfig.java index dbedadc5..d19b1c80 100644 --- a/hal-core/src/se/hal/intf/HalEventConfig.java +++ b/hal-core/src/se/hal/intf/HalEventConfig.java @@ -5,4 +5,10 @@ package se.hal.intf; */ public interface HalEventConfig extends HalDeviceConfig { + /** + * @return true if this event device is only a reporting data and do not accept writing/changing the data from Hal. + */ + default boolean isReadOnly() { + return false; + } } diff --git a/hal-core/src/se/hal/page/EventOverviewWebPage.java b/hal-core/src/se/hal/page/EventOverviewWebPage.java index 52e2e033..f0889b03 100644 --- a/hal-core/src/se/hal/page/EventOverviewWebPage.java +++ b/hal-core/src/se/hal/page/EventOverviewWebPage.java @@ -47,9 +47,9 @@ public class EventOverviewWebPage extends HalWebPage { // change event data OnOffEventData eventData = new OnOffEventData(); if (request.containsKey("enabled") && "on".equals(request.get("enabled"))) - eventData.turnOn(); + eventData.setOn(); else - eventData.turnOff(); + eventData.setOff(); logger.info("Modifying Event(" + id + ") state: " + eventData.toString()); Event event = Event.getEvent(db, id); diff --git a/hal-core/src/se/hal/struct/devicedata/LightSensorData.java b/hal-core/src/se/hal/struct/devicedata/IlluminanceSensorData.java similarity index 62% rename from hal-core/src/se/hal/struct/devicedata/LightSensorData.java rename to hal-core/src/se/hal/struct/devicedata/IlluminanceSensorData.java index f882f235..71055bd3 100644 --- a/hal-core/src/se/hal/struct/devicedata/LightSensorData.java +++ b/hal-core/src/se/hal/struct/devicedata/IlluminanceSensorData.java @@ -2,13 +2,14 @@ package se.hal.struct.devicedata; import se.hal.intf.HalSensorData; -public class LightSensorData extends HalSensorData { + +public class IlluminanceSensorData extends HalSensorData { private double lux; - public LightSensorData(){} - public LightSensorData(double lux, long timestamp){ + public IlluminanceSensorData(){} + public IlluminanceSensorData(double lux, long timestamp){ this.lux = lux; this.setTimestamp(timestamp); } @@ -16,7 +17,7 @@ public class LightSensorData extends HalSensorData { @Override public String toString(){ - return lux+" lux"; + return lux + " lux"; } // ---------------------------------------- @@ -32,10 +33,10 @@ public class LightSensorData extends HalSensorData { } /** - * @param lux set the light intensity in lux + * @param data set the light intensity in lux */ @Override - public void setData(double lux) { - this.lux = lux; + public void setData(double data) { + this.lux = data; } } diff --git a/hal-core/src/se/hal/struct/devicedata/OccupancyEventData.java b/hal-core/src/se/hal/struct/devicedata/OccupancyEventData.java new file mode 100644 index 00000000..4dd968d3 --- /dev/null +++ b/hal-core/src/se/hal/struct/devicedata/OccupancyEventData.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2015 Ziver + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package se.hal.struct.devicedata; + +import se.hal.intf.HalEventData; + + +public class OccupancyEventData extends HalEventData { + + private boolean isOccupied; + + + public OccupancyEventData() { } + public OccupancyEventData(boolean isOccupied, long timestamp) { + this.isOccupied = isOccupied; + this.setTimestamp(timestamp); + } + + public void setOccupied(){ + this.isOccupied = true; + } + public void setOccupied(boolean isOccupied){ + this.isOccupied = isOccupied; + } + public void setUnoccupied(){ + this.isOccupied = false; + } + public void toggle(){ + isOccupied = !isOccupied; + } + + public boolean isOccupied(){ + return isOccupied; + } + + @Override + public String toString(){ + return isOccupied ? "Occupied" : "Unoccupied"; + } + + // ---------------------------------------- + // Storage methods + // ---------------------------------------- + + @Override + public double getData() { + return (isOccupied ? 1.0 : 0.0); + } + + @Override + public void setData(double data) { + this.isOccupied = data > 0; + } +} diff --git a/hal-core/src/se/hal/struct/devicedata/OnOffEventData.java b/hal-core/src/se/hal/struct/devicedata/OnOffEventData.java index 8e34fa1e..4fe909d1 100644 --- a/hal-core/src/se/hal/struct/devicedata/OnOffEventData.java +++ b/hal-core/src/se/hal/struct/devicedata/OnOffEventData.java @@ -37,10 +37,10 @@ public class OnOffEventData extends HalEventData { } - public void turnOn(){ + public void setOn(){ isOn = true; } - public void turnOff(){ + public void setOff(){ isOn = false; } public void toggle(){ @@ -66,7 +66,7 @@ public class OnOffEventData extends HalEventData { } @Override - public void setData(double enabled) { - this.isOn = enabled > 0; + public void setData(double data) { + this.isOn = data > 0; } } diff --git a/hal-core/src/se/hal/struct/devicedata/OpenClosedEventData.java b/hal-core/src/se/hal/struct/devicedata/OpenClosedEventData.java index 24d8747c..45de33d7 100644 --- a/hal-core/src/se/hal/struct/devicedata/OpenClosedEventData.java +++ b/hal-core/src/se/hal/struct/devicedata/OpenClosedEventData.java @@ -36,10 +36,10 @@ public class OpenClosedEventData extends HalEventData { this.setTimestamp(timestamp); } - public void open(){ + public void setOpen(){ isOpen = true; } - public void close(){ + public void setClose(){ isOpen = false; } public void toggle(){ @@ -65,7 +65,7 @@ public class OpenClosedEventData extends HalEventData { } @Override - public void setData(double enabled) { - this.isOpen = enabled > 0; + public void setData(double data) { + this.isOpen = data > 0; } } diff --git a/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/trait/OnOffTrait.java b/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/trait/OnOffTrait.java index 048c087d..6db5517a 100644 --- a/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/trait/OnOffTrait.java +++ b/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/trait/OnOffTrait.java @@ -32,7 +32,6 @@ import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalDeviceData; import se.hal.struct.Event; import se.hal.struct.devicedata.OnOffEventData; -import se.hal.struct.devicedata.TemperatureSensorData; import java.util.HashMap; @@ -71,9 +70,9 @@ public class OnOffTrait extends DeviceTrait { if ("action.devices.commands.OnOff".equals(execution.command)) { OnOffEventData eventData = new OnOffEventData(); if ((boolean) execution.getParams().get("on")) - eventData.turnOn(); + eventData.setOn(); else - eventData.turnOff(); + eventData.setOff(); EventControllerManager.getInstance().send((Event) device, eventData); } diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java index 36815d64..f313248e 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java @@ -7,7 +7,7 @@ import se.hal.plugin.tellstick.TellstickDevice; import se.hal.plugin.tellstick.TellstickSerialComm; import se.hal.plugin.tellstick.protocol.Oregon0x1A2DProtocol; import se.hal.struct.devicedata.HumiditySensorData; -import se.hal.struct.devicedata.LightSensorData; +import se.hal.struct.devicedata.IlluminanceSensorData; import se.hal.struct.devicedata.PowerConsumptionSensorData; import se.hal.struct.devicedata.TemperatureSensorData; import zutil.log.LogUtil; @@ -78,7 +78,7 @@ public class Oregon0x1A2D implements TellstickDevice, HalSensorConfig { case HUMIDITY: return HumiditySensorData.class; case LIGHT: - return LightSensorData.class; + return IlluminanceSensorData.class; case POWER: return PowerConsumptionSensorData.class; case TEMPERATURE: diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/protocol/Oregon0x1A2DProtocol.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/protocol/Oregon0x1A2DProtocol.java index 8c62c647..e28ad0aa 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/protocol/Oregon0x1A2DProtocol.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/protocol/Oregon0x1A2DProtocol.java @@ -6,7 +6,7 @@ import se.hal.plugin.tellstick.TellstickSerialComm; import se.hal.plugin.tellstick.device.Oregon0x1A2D; import se.hal.plugin.tellstick.device.Oregon0x1A2D.OregonSensorType; import se.hal.struct.devicedata.HumiditySensorData; -import se.hal.struct.devicedata.LightSensorData; +import se.hal.struct.devicedata.IlluminanceSensorData; import se.hal.struct.devicedata.PowerConsumptionSensorData; import se.hal.struct.devicedata.TemperatureSensorData; import zutil.converter.Converter; @@ -90,7 +90,7 @@ public class Oregon0x1A2DProtocol extends TellstickProtocol { humidityFound = true; break; case LIGHT: - dataObj = new LightSensorData(temperature, timestamp); + dataObj = new IlluminanceSensorData(temperature, timestamp); temperatureFound = true; break; case TEMPERATURE: diff --git a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java index aa90bf10..25399b26 100644 --- a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java +++ b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java @@ -29,7 +29,7 @@ public class TelstickSerialCommNexaOnOffTest { System.out.println("Up and Running"); while (true) { Thread.sleep(2000); - nexaData.turnOn(); + nexaData.setOn(); nexaDevice.setUnit(0); comm.send(nexaDevice, nexaData); Thread.sleep(2000); @@ -38,7 +38,7 @@ public class TelstickSerialCommNexaOnOffTest { Thread.sleep(2000); - nexaData.turnOff(); + nexaData.setOff(); nexaDevice.setUnit(0); comm.send(nexaDevice, nexaData); Thread.sleep(2000); diff --git a/plugins/hal-zigbee/resource/resource/web/zigbee_network.tmpl b/plugins/hal-zigbee/resource/resource/web/zigbee_network.tmpl index 83ae4ad2..51cb5dd3 100644 --- a/plugins/hal-zigbee/resource/resource/web/zigbee_network.tmpl +++ b/plugins/hal-zigbee/resource/resource/web/zigbee_network.tmpl @@ -36,7 +36,9 @@
- Node: {{.getIeeeAddress()}} + + Node: {{.getIeeeAddress()}} +
@@ -100,7 +102,9 @@ {{#.getEndpoints()}}
@@ -109,7 +113,9 @@ {{#.inputClusters.values()}}
@@ -137,7 +143,9 @@ {{#.outputClusters.values()}}
diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigbeeController.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigbeeController.java index 461022ab..3c7a858a 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigbeeController.java +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigbeeController.java @@ -20,10 +20,12 @@ import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; import com.zsmartsystems.zigbee.zcl.ZclCluster; import com.zsmartsystems.zigbee.zcl.clusters.*; import com.zsmartsystems.zigbee.zdo.field.NodeDescriptor; + import se.hal.HalContext; import se.hal.intf.*; import se.hal.plugin.zigbee.db.ZigBeeHalDataStore; import se.hal.plugin.zigbee.device.*; + import zutil.Timer; import zutil.log.LogUtil; @@ -291,7 +293,7 @@ public class ZigbeeController implements HalSensorController, for (int inputClusterId : endpoint.getInputClusterIds()) { ZclCluster cluster = endpoint.getInputCluster(inputClusterId); - ZigbeeHalDeviceConfig config = createDeviceConfig(inputClusterId); + ZigbeeHalDeviceConfig config = ZigbeeHalDeviceFactory.getDeviceConfig(inputClusterId); // Read basic attributes if (cluster instanceof ZclBasicCluster) { @@ -338,18 +340,6 @@ public class ZigbeeController implements HalSensorController, } } - private ZigbeeHalDeviceConfig createDeviceConfig(int clusterId) { - switch (clusterId) { - case ZclRelativeHumidityMeasurementCluster.CLUSTER_ID: return new ZigbeeHumidityConfig(); - case ZclOnOffCluster.CLUSTER_ID: return new ZigbeeOnOffConfig(); - case ZclPressureMeasurementCluster.CLUSTER_ID: return new ZigbeePressureConfig(); - case ZclTemperatureMeasurementCluster.CLUSTER_ID: return new ZigbeeTemperatureConfig(); - } - - return null; - } - - @Override public void deviceRemoved(ZigBeeEndpoint endpoint) { logger.fine("[Node: " + endpoint.getIeeeAddress() + ", Endpoint: " + endpoint.getEndpointId() + "]: Endpoint removed: " + endpoint); diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHalDeviceFactory.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHalDeviceFactory.java new file mode 100644 index 00000000..b54226fc --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHalDeviceFactory.java @@ -0,0 +1,40 @@ +package se.hal.plugin.zigbee.device; + +import zutil.log.LogUtil; + +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * A factory class for getting new instances of {@link ZigbeeHalDeviceConfig} objects. + */ +public class ZigbeeHalDeviceFactory { + private static final Logger logger = LogUtil.getLogger(); + + private static final HashMap> clusterDeviceMap = new HashMap<>(); + static { + clusterDeviceMap.put(new ZigbeeHumidityConfig().getZigbeeClusterId(), ZigbeeHumidityConfig.class); + clusterDeviceMap.put(new ZigbeeIlluminanceConfig().getZigbeeClusterId(), ZigbeeIlluminanceConfig.class); + clusterDeviceMap.put(new ZigbeeOccupancyConfig().getZigbeeClusterId(), ZigbeeOccupancyConfig.class); + clusterDeviceMap.put(new ZigbeeOnOffConfig().getZigbeeClusterId(), ZigbeeOnOffConfig.class); + clusterDeviceMap.put(new ZigbeePressureConfig().getZigbeeClusterId(), ZigbeePressureConfig.class); + clusterDeviceMap.put(new ZigbeeTemperatureConfig().getZigbeeClusterId(), ZigbeeTemperatureConfig.class); + } + + + public static ZigbeeHalDeviceConfig getDeviceConfig(int cluster) { + try { + Class clazz = clusterDeviceMap.get(cluster); + + if (clazz != null) { + return clazz.getDeclaredConstructor().newInstance(); + } + } catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e) { + logger.log(Level.SEVERE, "Unable to instantiate ZigbeeHalDeviceConfig: " + clusterDeviceMap.get(cluster), e); + } + + return null; + } +} diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHalEventDeviceConfig.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHalEventDeviceConfig.java index 2b03c3ad..65832108 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHalEventDeviceConfig.java +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeHalEventDeviceConfig.java @@ -55,6 +55,8 @@ public abstract class ZigbeeHalEventDeviceConfig extends ZigbeeHalDeviceConfig { * @param data is the Hal event data value that should be converted. * @return a new Zigbee command object or null if no equal representation can be created based on the data. */ - protected abstract ZclCommand getZigbeeCommandObject(HalEventData data); + protected ZclCommand getZigbeeCommandObject(HalEventData data) { + return null; + } } diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeIlluminanceConfig.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeIlluminanceConfig.java new file mode 100644 index 00000000..e005fbd9 --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeIlluminanceConfig.java @@ -0,0 +1,46 @@ +package se.hal.plugin.zigbee.device; + +import com.zsmartsystems.zigbee.zcl.ZclAttribute; +import com.zsmartsystems.zigbee.zcl.clusters.ZclIlluminanceMeasurementCluster; +import se.hal.intf.HalDeviceData; +import se.hal.intf.HalSensorConfig; +import se.hal.struct.devicedata.IlluminanceSensorData; + +/** + * A device configuration for a specific endpoint on a Zigbee device. + */ +public class ZigbeeIlluminanceConfig extends ZigbeeHalDeviceConfig implements HalSensorConfig { + + // -------------------------- + // Zigbee Methods + // -------------------------- + + @Override + public HalDeviceData getDeviceData(ZclAttribute zclAttribute) { + if (zclAttribute.getCluster().getId() == getZigbeeClusterId() && + zclAttribute.getId() == ZclIlluminanceMeasurementCluster.ATTR_MEASUREDVALUE) + return new IlluminanceSensorData( + (int) zclAttribute.getLastValue(), + zclAttribute.getLastReportTime().getTimeInMillis()); + return null; + } + + @Override + public int getZigbeeClusterId() { + return ZclIlluminanceMeasurementCluster.CLUSTER_ID; + } + + // -------------------------- + // Hal Methods + // -------------------------- + + @Override + public AggregationMethod getAggregationMethod() { + return AggregationMethod.AVERAGE; + } + + @Override + public Class getDeviceDataClass() { + return IlluminanceSensorData.class; + } +} diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeOccupancyConfig.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeOccupancyConfig.java new file mode 100644 index 00000000..618f0193 --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/device/ZigbeeOccupancyConfig.java @@ -0,0 +1,62 @@ +package se.hal.plugin.zigbee.device; + +import com.zsmartsystems.zigbee.zcl.ZclAttribute; +import com.zsmartsystems.zigbee.zcl.ZclCluster; +import com.zsmartsystems.zigbee.zcl.clusters.ZclOccupancySensingCluster; + +import se.hal.intf.HalDeviceData; +import se.hal.intf.HalEventConfig; +import se.hal.struct.devicedata.OccupancyEventData; +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 ZigbeeOccupancyConfig extends ZigbeeHalEventDeviceConfig implements HalEventConfig { + private static final Logger logger = LogUtil.getLogger(); + + // -------------------------- + // Zigbee Methods + // -------------------------- + + @Override + public void initialize(ZclCluster cluster) { + if (! (cluster instanceof ZclOccupancySensingCluster)) + return; + + try { + ZclAttribute attribute = cluster.getAttribute(ZclOccupancySensingCluster.ATTR_OCCUPANCY); + 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.getCluster().getId() == getZigbeeClusterId() && + zclAttribute.getId() == ZclOccupancySensingCluster.ATTR_OCCUPANCY) + return new OccupancyEventData( + (boolean) zclAttribute.getLastValue(), + zclAttribute.getLastReportTime().getTimeInMillis()); + return null; + } + + @Override + public int getZigbeeClusterId() { + return ZclOccupancySensingCluster.CLUSTER_ID; + } + + // -------------------------- + // Hal Methods + // -------------------------- + + @Override + public Class getDeviceDataClass() { + return OccupancyEventData.class; + } +} 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 93c77b1b..a9ff6ae6 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 @@ -20,7 +20,7 @@ public class ZigbeePressureConfig extends ZigbeeHalDeviceConfig implements HalSe @Override public HalDeviceData getDeviceData(ZclAttribute zclAttribute) { if (zclAttribute.getCluster().getId() == getZigbeeClusterId() && - zclAttribute.getId() == ZclTemperatureMeasurementCluster.ATTR_MAXMEASUREDVALUE) + zclAttribute.getId() == ZclTemperatureMeasurementCluster.ATTR_MEASUREDVALUE) return new PressureSensorData( (int) zclAttribute.getLastValue(), zclAttribute.getLastReportTime().getTimeInMillis()); diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/plugin.json b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/plugin.json index e2a77789..a452cd78 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/plugin.json +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/plugin.json @@ -7,6 +7,8 @@ {"se.hal.intf.HalEventConfig": "se.hal.plugin.zigbee.device.ZigbeeOnOffConfig"}, {"se.hal.intf.HalSensorConfig": "se.hal.plugin.zigbee.device.ZigbeeHumidityConfig"}, + {"se.hal.intf.HalSensorConfig": "se.hal.plugin.zigbee.device.ZigbeeIlluminanceConfig"}, + {"se.hal.intf.HalEventConfig": "se.hal.plugin.zigbee.device.ZigbeeOccupancyConfig"}, {"se.hal.intf.HalSensorConfig": "se.hal.plugin.zigbee.device.ZigbeePressureConfig"}, {"se.hal.intf.HalSensorConfig": "se.hal.plugin.zigbee.device.ZigbeeTemperatureConfig"},