From 4afeea3fb630fcd40a3a965c1d08dfb977f85e27 Mon Sep 17 00:00:00 2001 From: Lucas Christian Date: Sun, 5 Jun 2022 12:05:48 -0700 Subject: [PATCH 1/3] Use Dimensionless unit for Relative Humidity + add reporting config Signed-off-by: Lucas Christian --- org.openhab.binding.zigbee/README.md | 2 +- .../zigbee/ZigBeeBindingConstants.java | 1 + .../ZigBeeConverterRelativeHumidity.java | 51 ++++++++++++++++--- .../main/resources/OH-INF/thing/channels.xml | 4 +- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/org.openhab.binding.zigbee/README.md b/org.openhab.binding.zigbee/README.md index 7e6d433bf..c84352956 100644 --- a/org.openhab.binding.zigbee/README.md +++ b/org.openhab.binding.zigbee/README.md @@ -392,7 +392,7 @@ The following channels are supported -: | ias_tamper | `IAS_ZONE` (0x0500) | Switch | | | measurement_illuminance | `ILLUMINANCE_MEASUREMENT` (0x0400) | Number | | | measurement_pressure | `PRESSURE_MEASUREMENT` (0x0403) | Number:Pressure | | -| measurement_relativehumidity | `RELATIVE_HUMIDITY_MEASUREMENT` (0x0405) | Number | | +| measurement_relativehumidity | `RELATIVE_HUMIDITY_MEASUREMENT` (0x0405) | Number:Dimensionless | | | measurement_temperature | `TEMPERATURE_MEASUREMENT` (0x0402) | Number:Temperature | | | metering_instantdemand | `METERING` (0x0702) | Number | | | metering_sumdelivered | `METERING` (0x0702) | Number | | diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java index 7e787c5d6..05e8e4f0a 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java @@ -242,6 +242,7 @@ public class ZigBeeBindingConstants { public static final String ITEM_TYPE_CONTACT = "Contact"; public static final String ITEM_TYPE_DIMMER = "Dimmer"; public static final String ITEM_TYPE_NUMBER = "Number"; + public static final String ITEM_TYPE_NUMBER_DIMENSIONLESS = "Number:Dimensionless"; public static final String ITEM_TYPE_NUMBER_PRESSURE = "Number:Pressure"; public static final String ITEM_TYPE_NUMBER_TEMPERATURE = "Number:Temperature"; public static final String ITEM_TYPE_ROLLERSHUTTER = "Rollershutter"; diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterRelativeHumidity.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterRelativeHumidity.java index 78fb519ba..c4d9b5eff 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterRelativeHumidity.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterRelativeHumidity.java @@ -13,14 +13,18 @@ package org.openhab.binding.zigbee.internal.converter; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Collections; +import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; +import org.eclipse.jdt.annotation.NonNull; import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; -import org.openhab.core.library.types.DecimalType; +import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; +import org.openhab.core.config.core.Configuration; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; @@ -43,8 +47,13 @@ public class ZigBeeConverterRelativeHumidity extends ZigBeeBaseChannelConverter implements ZclAttributeListener { private Logger logger = LoggerFactory.getLogger(ZigBeeConverterRelativeHumidity.class); + private static BigDecimal CHANGE_DEFAULT = new BigDecimal(50); + private static BigDecimal CHANGE_MIN = new BigDecimal(1); + private static BigDecimal CHANGE_MAX = new BigDecimal(10000); + private ZclRelativeHumidityMeasurementCluster cluster; private ZclAttribute attribute; + private ZclReportingConfig configReporting; @Override public Set getImplementedClientClusters() { @@ -65,15 +74,17 @@ public boolean initializeDevice() { return false; } + ZclReportingConfig reporting = new ZclReportingConfig(channel); + try { CommandResult bindResponse = bind(serverCluster).get(); if (bindResponse.isSuccess()) { // Configure reporting ZclAttribute attribute = serverCluster .getAttribute(ZclRelativeHumidityMeasurementCluster.ATTR_MEASUREDVALUE); - CommandResult reportingResponse = attribute - .setReporting(REPORTING_PERIOD_DEFAULT_MIN, REPORTING_PERIOD_DEFAULT_MAX, 50).get(); - handleReportingResponse(reportingResponse, POLLING_PERIOD_DEFAULT, REPORTING_PERIOD_DEFAULT_MAX); + CommandResult reportingResponse = attribute.setReporting(reporting.getReportingTimeMin(), + reporting.getReportingTimeMax(), reporting.getReportingChange()).get(); + handleReportingResponse(reportingResponse, POLLING_PERIOD_DEFAULT, reporting.getPollingPeriod()); } } catch (InterruptedException | ExecutionException e) { logger.error("{}: Exception setting reporting ", endpoint.getIeeeAddress(), e); @@ -99,6 +110,12 @@ public boolean initializeConverter(ZigBeeThingHandler thing) { return false; } + // Add reporting configuration + configReporting = new ZclReportingConfig(channel); + configReporting.setAnalogue(CHANGE_DEFAULT, CHANGE_MIN, CHANGE_MAX); + configOptions = new ArrayList<>(); + configOptions.addAll(configReporting.getConfiguration()); + // Add a listener, then request the status cluster.addAttributeListener(this); return true; @@ -109,11 +126,33 @@ public void disposeConverter() { cluster.removeAttributeListener(this); } + @Override + public int getPollingPeriod() { + return configReporting.getPollingPeriod(); + } + @Override public void handleRefresh() { attribute.readValue(0); } + @Override + public void updateConfiguration(@NonNull Configuration currentConfiguration, + Map updatedParameters) { + if (configReporting.updateConfiguration(currentConfiguration, updatedParameters)) { + try { + ZclAttribute attribute = cluster.getAttribute(ZclRelativeHumidityMeasurementCluster.ATTR_MEASUREDVALUE); + CommandResult reportingResponse; + reportingResponse = attribute.setReporting(configReporting.getReportingTimeMin(), + configReporting.getReportingTimeMax(), configReporting.getReportingChange()).get(); + handleReportingResponse(reportingResponse, configReporting.getPollingPeriod(), + configReporting.getReportingTimeMax()); + } catch (InterruptedException | ExecutionException e) { + logger.debug("{}: Relative humidity measurement exception setting reporting", endpoint.getIeeeAddress(), e); + } + } + } + @Override public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { if (endpoint.getInputCluster(ZclRelativeHumidityMeasurementCluster.CLUSTER_ID) == null) { @@ -123,7 +162,7 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_HUMIDITY_VALUE), - ZigBeeBindingConstants.ITEM_TYPE_NUMBER) + ZigBeeBindingConstants.ITEM_TYPE_NUMBER_DIMENSIONLESS) .withType(ZigBeeBindingConstants.CHANNEL_HUMIDITY_VALUE) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_HUMIDITY_VALUE) .withProperties(createProperties(endpoint)).build(); @@ -135,7 +174,7 @@ public void attributeUpdated(ZclAttribute attribute, Object val) { if (attribute.getClusterType() == ZclClusterType.RELATIVE_HUMIDITY_MEASUREMENT && attribute.getId() == ZclRelativeHumidityMeasurementCluster.ATTR_MEASUREDVALUE) { Integer value = (Integer) val; - updateChannelState(new DecimalType(BigDecimal.valueOf(value, 2))); + updateChannelState(valueToPercentDimensionless(BigDecimal.valueOf(value, 2))); } } } diff --git a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/channels.xml b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/channels.xml index c7f46b42c..626e56101 100644 --- a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/channels.xml +++ b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/channels.xml @@ -215,11 +215,11 @@ - Number + Number:Dimensionless Indicates the current relative humidity Humidity - + From 3623c2b60e329f01075a0f8bd38208f08055a912 Mon Sep 17 00:00:00 2001 From: Lucas Christian Date: Sun, 5 Jun 2022 22:11:47 -0700 Subject: [PATCH 2/3] Fix dynamically defined channels missing units of measure Signed-off-by: Lucas Christian --- org.openhab.binding.zigbee/README.md | 12 ++++++------ .../binding/zigbee/ZigBeeBindingConstants.java | 3 +++ .../converter/ZigBeeConverterMeasurementPower.java | 2 +- .../ZigBeeConverterMeasurementRmsCurrent.java | 2 +- .../ZigBeeConverterMeasurementRmsVoltage.java | 2 +- .../ZigBeeConverterThermostatPiCoolingDemand.java | 2 +- .../ZigBeeConverterThermostatPiHeatingDemand.java | 2 +- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/org.openhab.binding.zigbee/README.md b/org.openhab.binding.zigbee/README.md index c84352956..7b983e0a7 100644 --- a/org.openhab.binding.zigbee/README.md +++ b/org.openhab.binding.zigbee/README.md @@ -400,14 +400,14 @@ The following channels are supported -: | sensor_occupancy | `OCCUPANCY_SENSING` (0x0406) | Switch | | | switch_dimmer | `LEVEL_CONTROL` (0x0008) | Dimmer | | | switch_onoff | `ON_OFF` (0x0006) | Switch | | -| thermostat_localtemp | `THERMOSTAT` (0x0201) | Number | | -| thermostat_occupiedcooling | `THERMOSTAT` (0x0201) | Number | | -| thermostat_occupiedheating | `THERMOSTAT` (0x0201) | Number | | -| thermostat_outdoortemp | `THERMOSTAT` (0x0201) | Number | | +| thermostat_localtemp | `THERMOSTAT` (0x0201) | Number:Temperature | | +| thermostat_occupiedcooling | `THERMOSTAT` (0x0201) | Number:Temperature | | +| thermostat_occupiedheating | `THERMOSTAT` (0x0201) | Number:Temperature | | +| thermostat_outdoortemp | `THERMOSTAT` (0x0201) | Number:Temperature | | | thermostat_runningmode | `THERMOSTAT` (0x0201) | Number | | | thermostat_systemmode | `THERMOSTAT` (0x0201) | Number | | -| thermostat_unoccupiedcooling | `THERMOSTAT` (0x0201) | Number | | -| thermostat_unoccupiedheating | `THERMOSTAT` (0x0201) | Number | | +| thermostat_unoccupiedcooling | `THERMOSTAT` (0x0201) | Number:Temperature | | +| thermostat_unoccupiedheating | `THERMOSTAT` (0x0201) | Number:Temperature | | | thermostat_heatingdemand | `THERMOSTAT` (0x0201) | Number:Dimensionless | | | thermostat_coolingdemand | `THERMOSTAT` (0x0201) | Number:Dimensionless | | | warning_device | `IAS_WD` (0x0502) | String | | diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java index 05e8e4f0a..fadc2cf4e 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java @@ -243,6 +243,9 @@ public class ZigBeeBindingConstants { public static final String ITEM_TYPE_DIMMER = "Dimmer"; public static final String ITEM_TYPE_NUMBER = "Number"; public static final String ITEM_TYPE_NUMBER_DIMENSIONLESS = "Number:Dimensionless"; + public static final String ITEM_TYPE_NUMBER_ELECTRICCURRENT = "Number:ElectricCurrent"; + public static final String ITEM_TYPE_NUMBER_ELECTRICPOTENTIAL = "Number:ElectricPotential"; + public static final String ITEM_TYPE_NUMBER_POWER = "Number:Power"; public static final String ITEM_TYPE_NUMBER_PRESSURE = "Number:Pressure"; public static final String ITEM_TYPE_NUMBER_TEMPERATURE = "Number:Temperature"; public static final String ITEM_TYPE_ROLLERSHUTTER = "Rollershutter"; diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementPower.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementPower.java index ebfbd99ec..e200530b1 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementPower.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementPower.java @@ -145,7 +145,7 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_ELECTRICAL_ACTIVEPOWER), - ZigBeeBindingConstants.ITEM_TYPE_NUMBER) + ZigBeeBindingConstants.ITEM_TYPE_NUMBER_POWER) .withType(ZigBeeBindingConstants.CHANNEL_ELECTRICAL_ACTIVEPOWER) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_ELECTRICAL_ACTIVEPOWER) .withProperties(createProperties(endpoint)).build(); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementRmsCurrent.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementRmsCurrent.java index 05914a245..f8703f546 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementRmsCurrent.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementRmsCurrent.java @@ -148,7 +148,7 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_ELECTRICAL_RMSCURRENT), - ZigBeeBindingConstants.ITEM_TYPE_NUMBER) + ZigBeeBindingConstants.ITEM_TYPE_NUMBER_ELECTRICCURRENT) .withType(ZigBeeBindingConstants.CHANNEL_ELECTRICAL_RMSCURRENT) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_ELECTRICAL_RMSCURRENT) .withProperties(createProperties(endpoint)).build(); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementRmsVoltage.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementRmsVoltage.java index b5d78b1b0..686c92194 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementRmsVoltage.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeasurementRmsVoltage.java @@ -148,7 +148,7 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_ELECTRICAL_RMSVOLTAGE), - ZigBeeBindingConstants.ITEM_TYPE_NUMBER) + ZigBeeBindingConstants.ITEM_TYPE_NUMBER_ELECTRICPOTENTIAL) .withType(ZigBeeBindingConstants.CHANNEL_ELECTRICAL_RMSVOLTAGE) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_ELECTRICAL_RMSVOLTAGE) .withProperties(createProperties(endpoint)).build(); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatPiCoolingDemand.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatPiCoolingDemand.java index e4c710554..8f3f3eeb5 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatPiCoolingDemand.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatPiCoolingDemand.java @@ -172,7 +172,7 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_THERMOSTAT_COOLING_DEMAND), - ZigBeeBindingConstants.ITEM_TYPE_NUMBER) + ZigBeeBindingConstants.ITEM_TYPE_NUMBER_DIMENSIONLESS) .withType(ZigBeeBindingConstants.CHANNEL_THERMOSTAT_COOLING_DEMAND) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_THERMOSTAT_COOLING_DEMAND) .withProperties(createProperties(endpoint)).build(); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatPiHeatingDemand.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatPiHeatingDemand.java index 12d68b531..bf1b232a8 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatPiHeatingDemand.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatPiHeatingDemand.java @@ -172,7 +172,7 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_THERMOSTAT_HEATING_DEMAND), - ZigBeeBindingConstants.ITEM_TYPE_NUMBER) + ZigBeeBindingConstants.ITEM_TYPE_NUMBER_DIMENSIONLESS) .withType(ZigBeeBindingConstants.CHANNEL_THERMOSTAT_HEATING_DEMAND) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_THERMOSTAT_HEATING_DEMAND) .withProperties(createProperties(endpoint)).build(); From 72c2a6ed0d2f7d3d14203afe5f7d17fad704cbbb Mon Sep 17 00:00:00 2001 From: Lucas Christian Date: Sun, 5 Jun 2022 22:12:29 -0700 Subject: [PATCH 3/3] Add unit of measure to Illuminance channel Signed-off-by: Lucas Christian --- org.openhab.binding.zigbee/README.md | 2 +- .../org/openhab/binding/zigbee/ZigBeeBindingConstants.java | 1 + .../internal/converter/ZigBeeConverterIlluminance.java | 6 ++++-- .../src/main/resources/OH-INF/thing/channels.xml | 6 +++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/org.openhab.binding.zigbee/README.md b/org.openhab.binding.zigbee/README.md index 7b983e0a7..cbc74a9ae 100644 --- a/org.openhab.binding.zigbee/README.md +++ b/org.openhab.binding.zigbee/README.md @@ -390,7 +390,7 @@ The following channels are supported -: | ias_vibration | `IAS_ZONE` (0x0500) | Switch | | | ias_tamper | `IAS_ZONE` (0x0500) | Switch | | | ias_tamper | `IAS_ZONE` (0x0500) | Switch | | -| measurement_illuminance | `ILLUMINANCE_MEASUREMENT` (0x0400) | Number | | +| measurement_illuminance | `ILLUMINANCE_MEASUREMENT` (0x0400) | Number:Illuminance | | | measurement_pressure | `PRESSURE_MEASUREMENT` (0x0403) | Number:Pressure | | | measurement_relativehumidity | `RELATIVE_HUMIDITY_MEASUREMENT` (0x0405) | Number:Dimensionless | | | measurement_temperature | `TEMPERATURE_MEASUREMENT` (0x0402) | Number:Temperature | | diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java index fadc2cf4e..6ca319dfa 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java @@ -245,6 +245,7 @@ public class ZigBeeBindingConstants { public static final String ITEM_TYPE_NUMBER_DIMENSIONLESS = "Number:Dimensionless"; public static final String ITEM_TYPE_NUMBER_ELECTRICCURRENT = "Number:ElectricCurrent"; public static final String ITEM_TYPE_NUMBER_ELECTRICPOTENTIAL = "Number:ElectricPotential"; + public static final String ITEM_TYPE_NUMBER_ILLUMINANCE = "Number:Illuminance"; public static final String ITEM_TYPE_NUMBER_POWER = "Number:Power"; public static final String ITEM_TYPE_NUMBER_PRESSURE = "Number:Pressure"; public static final String ITEM_TYPE_NUMBER_TEMPERATURE = "Number:Temperature"; diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIlluminance.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIlluminance.java index 6758ff195..8b0e259a2 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIlluminance.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIlluminance.java @@ -26,6 +26,8 @@ import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; import org.openhab.core.config.core.Configuration; import org.openhab.core.library.types.DecimalType; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.unit.Units; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; @@ -163,7 +165,7 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { } return ChannelBuilder .create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_ILLUMINANCE_VALUE), - ZigBeeBindingConstants.ITEM_TYPE_NUMBER) + ZigBeeBindingConstants.ITEM_TYPE_NUMBER_ILLUMINANCE) .withType(ZigBeeBindingConstants.CHANNEL_ILLUMINANCE_VALUE) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_ILLUMINANCE_VALUE) .withProperties(createProperties(endpoint)).build(); @@ -174,7 +176,7 @@ public void attributeUpdated(ZclAttribute attribute, Object val) { logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute); if (attribute.getClusterType() == ZclClusterType.ILLUMINANCE_MEASUREMENT && attribute.getId() == ZclIlluminanceMeasurementCluster.ATTR_MEASUREDVALUE) { - updateChannelState(new DecimalType(Math.pow(10.0, (Integer) val / 10000.0) - 1)); + updateChannelState(new QuantityType<>(new DecimalType(Math.pow(10.0, (Integer) val / 10000.0) - 1), Units.LUX)); } } } diff --git a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/channels.xml b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/channels.xml index 626e56101..e6ac41423 100644 --- a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/channels.xml +++ b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/channels.xml @@ -197,11 +197,11 @@ - Number + Number:Illuminance - Indicates the current illuminance in lux + Indicates the current illuminance - +