From 60d87900f9f8f7f8c734b30976a038eb07bbd01c Mon Sep 17 00:00:00 2001 From: AndrewFG Date: Mon, 28 Oct 2024 14:10:04 +0000 Subject: [PATCH 1/5] [zigbee] Add color temperature absolute channel Signed-off-by: AndrewFG --- .../zigbee/ZigBeeBindingConstants.java | 3 + .../zigbee/handler/ZigBeeThingHandler.java | 4 + .../ZigBeeConverterColorTemperature.java | 6 +- .../ZigBeeConverterColorTemperatureAbs.java | 107 ++++++++++++++++++ ...ZigBeeDefaultChannelConverterProvider.java | 1 + 5 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java 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 6d62823d4..9dfcc9219 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 @@ -58,6 +58,9 @@ public class ZigBeeBindingConstants { public static final String CHANNEL_LABEL_COLOR_TEMPERATURE = "Color Temperature"; public static final ChannelTypeUID CHANNEL_COLOR_TEMPERATURE = SYSTEM_COLOR_TEMPERATURE.getUID(); + public static final String CHANNEL_NAME_COLOR_TEMPERATURE_ABS = "colortemperature_abs"; + public static final ChannelTypeUID CHANNEL_COLOR_TEMPERATURE_ABS = SYSTEM_COLOR_TEMPERATURE_ABS.getUID(); + public static final String CHANNEL_NAME_ILLUMINANCE_VALUE = "illuminance"; public static final String CHANNEL_LABEL_ILLUMINANCE_VALUE = "Illuminance"; public static final ChannelTypeUID CHANNEL_ILLUMINANCE_VALUE = new ChannelTypeUID("zigbee:measurement_illuminance"); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java index 8f5f94a40..109bc4d22 100755 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java @@ -1149,4 +1149,8 @@ public boolean isDeviceInitialized() { public ZigBeeNode getNode() { return coordinatorHandler.getNode(nodeIeeeAddress); } + + public void putStateDescription(ChannelUID channelUID, StateDescription stateDescription) { + stateDescriptions.put(channelUID, stateDescription); + } } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java index d1ba182ae..1083acc80 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java @@ -52,11 +52,11 @@ public class ZigBeeConverterColorTemperature extends ZigBeeBaseChannelConverter private Logger logger = LoggerFactory.getLogger(ZigBeeConverterColorTemperature.class); - private ZclColorControlCluster clusterColorControl; + protected ZclColorControlCluster clusterColorControl; private ZclOnOffCluster clusterOnOff; - private double kelvinMin; - private double kelvinMax; + protected double kelvinMin; + protected double kelvinMax; private double kelvinRange; // Default range of 2000K to 6500K diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java new file mode 100644 index 000000000..8b618cecf --- /dev/null +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java @@ -0,0 +1,107 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.zigbee.internal.converter; + +import java.math.BigDecimal; + +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; +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; +import org.openhab.core.types.Command; +import org.openhab.core.types.StateDescriptionFragmentBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.zsmartsystems.zigbee.IeeeAddress; +import com.zsmartsystems.zigbee.ZigBeeEndpoint; +import com.zsmartsystems.zigbee.zcl.ZclAttribute; +import com.zsmartsystems.zigbee.zcl.clusters.ZclColorControlCluster; +import com.zsmartsystems.zigbee.zcl.clusters.colorcontrol.MoveToColorTemperatureCommand; +import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; + +import tech.units.indriya.unit.UnitDimension; + +/** + * Channel converter for color temperature, converting between the color control cluster and a Kelvin + * QuantityType channel. + * + * @author Andrew Fiddian-Green - Initial Contribution + */ +public class ZigBeeConverterColorTemperatureAbs extends ZigBeeConverterColorTemperature { + + private Logger logger = LoggerFactory.getLogger(ZigBeeConverterColorTemperatureAbs.class); + + private boolean updateStateDescriptionDone; + + @Override + public void initialize(Channel channel, ZigBeeCoordinatorHandler coordinator, IeeeAddress address, int endpointId) { + super.initialize(channel, coordinator, address, endpointId); + updateStateDescriptionDone = false; + } + + @Override + public void handleCommand(final Command command) { + if (command instanceof QuantityType quantity && UnitDimension.TEMPERATURE == quantity.getDimension()) { + QuantityType kelvin = quantity.toInvertibleUnit(Units.KELVIN); + if (kelvin != null) { + logger.debug("handleCommand() channel {} to {}", channelUID, kelvin); + MoveToColorTemperatureCommand zclCommand = new MoveToColorTemperatureCommand( + 1000000 / kelvin.intValue(), 10); + monitorCommandResponse(command, clusterColorControl.sendCommand(zclCommand)); + } + } else { + super.handleCommand(command); + } + } + + @Override + public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { + return super.getChannel(thingUID, endpoint) == null ? null + : ChannelBuilder + .create(createChannelUID(thingUID, endpoint, + ZigBeeBindingConstants.CHANNEL_NAME_COLOR_TEMPERATURE_ABS), + ZigBeeBindingConstants.ITEM_TYPE_NUMBER_TEMPERATURE) + .withType(ZigBeeBindingConstants.CHANNEL_COLOR_TEMPERATURE_ABS) + .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_COLOR_TEMPERATURE) + .withProperties(createProperties(endpoint)).build(); + } + + @Override + public void attributeUpdated(ZclAttribute attribute, Object val) { + if (attribute.getClusterType() == ZclClusterType.COLOR_CONTROL + && attribute.getId() == ZclColorControlCluster.ATTR_COLORTEMPERATURE && val instanceof Integer mired) { + updateStateDescription(); + updateChannelState(QuantityType.valueOf(1000000 / mired, Units.KELVIN)); + } else { + super.attributeUpdated(attribute, val); + } + } + + /** + * Set the state description minimum and maximum values and pattern in Kelvin for the given channel UID + */ + private void updateStateDescription() { + if (!updateStateDescriptionDone) { + updateStateDescriptionDone = true; + logger.debug("updateStateDescription() {} state min/max = {}/{} Kelvin", channelUID, kelvinMin, kelvinMax); + thing.putStateDescription(channelUID, + StateDescriptionFragmentBuilder.create().withMinimum(BigDecimal.valueOf(kelvinMin)) + .withMaximum(BigDecimal.valueOf(kelvinMax)).withStep(BigDecimal.valueOf(100)) + .withPattern("%.0f K").build().toStateDescription()); + } + } +} diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeDefaultChannelConverterProvider.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeDefaultChannelConverterProvider.java index d02ef25e3..cbdb5101b 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeDefaultChannelConverterProvider.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeDefaultChannelConverterProvider.java @@ -39,6 +39,7 @@ public ZigBeeDefaultChannelConverterProvider() { // Add all the converters into the map... channelMap.put(ZigBeeBindingConstants.CHANNEL_COLOR_COLOR, ZigBeeConverterColorColor.class); channelMap.put(ZigBeeBindingConstants.CHANNEL_COLOR_TEMPERATURE, ZigBeeConverterColorTemperature.class); + channelMap.put(ZigBeeBindingConstants.CHANNEL_COLOR_TEMPERATURE_ABS, ZigBeeConverterColorTemperatureAbs.class); channelMap.put(ZigBeeBindingConstants.CHANNEL_DOORLOCK_STATE, ZigBeeConverterDoorLock.class); channelMap.put(ZigBeeBindingConstants.CHANNEL_ELECTRICAL_ACTIVEPOWER, ZigBeeConverterMeasurementPower.class); channelMap.put(ZigBeeBindingConstants.CHANNEL_HUMIDITY_VALUE, ZigBeeConverterRelativeHumidity.class); From 4f7b86b33553536aed3d4ff6c700da60336843da Mon Sep 17 00:00:00 2001 From: AndrewFG Date: Tue, 29 Oct 2024 14:56:09 +0000 Subject: [PATCH 2/5] adopt reviewer suggestions Signed-off-by: AndrewFG --- .../zigbee/handler/ZigBeeThingHandler.java | 4 -- .../ZigBeeConverterColorTemperatureAbs.java | 59 ++++++++----------- 2 files changed, 23 insertions(+), 40 deletions(-) diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java index 109bc4d22..8f5f94a40 100755 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java @@ -1149,8 +1149,4 @@ public boolean isDeviceInitialized() { public ZigBeeNode getNode() { return coordinatorHandler.getNode(nodeIeeeAddress); } - - public void putStateDescription(ChannelUID channelUID, StateDescription stateDescription) { - stateDescriptions.put(channelUID, stateDescription); - } } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java index 8b618cecf..e81856888 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java @@ -15,7 +15,7 @@ import java.math.BigDecimal; import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; +import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.unit.Units; import org.openhab.core.thing.Channel; @@ -26,15 +26,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.zsmartsystems.zigbee.IeeeAddress; import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.ZclAttribute; import com.zsmartsystems.zigbee.zcl.clusters.ZclColorControlCluster; import com.zsmartsystems.zigbee.zcl.clusters.colorcontrol.MoveToColorTemperatureCommand; import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; -import tech.units.indriya.unit.UnitDimension; - /** * Channel converter for color temperature, converting between the color control cluster and a Kelvin * QuantityType channel. @@ -45,27 +42,28 @@ public class ZigBeeConverterColorTemperatureAbs extends ZigBeeConverterColorTemp private Logger logger = LoggerFactory.getLogger(ZigBeeConverterColorTemperatureAbs.class); - private boolean updateStateDescriptionDone; - @Override - public void initialize(Channel channel, ZigBeeCoordinatorHandler coordinator, IeeeAddress address, int endpointId) { - super.initialize(channel, coordinator, address, endpointId); - updateStateDescriptionDone = false; + public boolean initializeConverter(ZigBeeThingHandler thing) { + if (super.initializeConverter(thing)) { + stateDescription = StateDescriptionFragmentBuilder.create().withMinimum(BigDecimal.valueOf(kelvinMin)) + .withMaximum(BigDecimal.valueOf(kelvinMax)).withStep(BigDecimal.valueOf(100)).withPattern("%.0f K") + .build().toStateDescription(); + return true; + } + return false; } @Override public void handleCommand(final Command command) { - if (command instanceof QuantityType quantity && UnitDimension.TEMPERATURE == quantity.getDimension()) { - QuantityType kelvin = quantity.toInvertibleUnit(Units.KELVIN); - if (kelvin != null) { - logger.debug("handleCommand() channel {} to {}", channelUID, kelvin); - MoveToColorTemperatureCommand zclCommand = new MoveToColorTemperatureCommand( - 1000000 / kelvin.intValue(), 10); + if (command instanceof QuantityType quantity) { + QuantityType mired = quantity.toInvertibleUnit(Units.MIRED); + if (mired != null) { + MoveToColorTemperatureCommand zclCommand = new MoveToColorTemperatureCommand(mired.intValue(), 10); monitorCommandResponse(command, clusterColorControl.sendCommand(zclCommand)); } - } else { - super.handleCommand(command); + return; } + super.handleCommand(command); } @Override @@ -83,25 +81,14 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { @Override public void attributeUpdated(ZclAttribute attribute, Object val) { if (attribute.getClusterType() == ZclClusterType.COLOR_CONTROL - && attribute.getId() == ZclColorControlCluster.ATTR_COLORTEMPERATURE && val instanceof Integer mired) { - updateStateDescription(); - updateChannelState(QuantityType.valueOf(1000000 / mired, Units.KELVIN)); - } else { - super.attributeUpdated(attribute, val); - } - } - - /** - * Set the state description minimum and maximum values and pattern in Kelvin for the given channel UID - */ - private void updateStateDescription() { - if (!updateStateDescriptionDone) { - updateStateDescriptionDone = true; - logger.debug("updateStateDescription() {} state min/max = {}/{} Kelvin", channelUID, kelvinMin, kelvinMax); - thing.putStateDescription(channelUID, - StateDescriptionFragmentBuilder.create().withMinimum(BigDecimal.valueOf(kelvinMin)) - .withMaximum(BigDecimal.valueOf(kelvinMax)).withStep(BigDecimal.valueOf(100)) - .withPattern("%.0f K").build().toStateDescription()); + && attribute.getId() == ZclColorControlCluster.ATTR_COLORTEMPERATURE) { + logger.debug("{}: ZigBee attribute reports {} on endpoint {}", endpoint.getIeeeAddress(), attribute, + endpoint.getEndpointId()); + if (val instanceof Integer mired) { + updateChannelState(QuantityType.valueOf(1000000 / mired, Units.KELVIN)); + } + return; } + super.attributeUpdated(attribute, val); } } From 77e48b0d70cefab600c030bdf7cdd31a24082a41 Mon Sep 17 00:00:00 2001 From: AndrewFG Date: Tue, 29 Oct 2024 15:05:59 +0000 Subject: [PATCH 3/5] doc and quality improvements Signed-off-by: AndrewFG --- .../converter/ZigBeeConverterColorTemperatureAbs.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java index e81856888..f9933b158 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java @@ -33,8 +33,8 @@ import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; /** - * Channel converter for color temperature, converting between the color control cluster and a Kelvin - * QuantityType channel. + * Channel converter for absolute color temperature based on {@link ZigBeeConverterColorTemperature}, that converts + * between the color control cluster and a QuantityType channel. * * @author Andrew Fiddian-Green - Initial Contribution */ @@ -85,7 +85,7 @@ public void attributeUpdated(ZclAttribute attribute, Object val) { logger.debug("{}: ZigBee attribute reports {} on endpoint {}", endpoint.getIeeeAddress(), attribute, endpoint.getEndpointId()); if (val instanceof Integer mired) { - updateChannelState(QuantityType.valueOf(1000000 / mired, Units.KELVIN)); + updateChannelState(QuantityType.valueOf(mired, Units.MIRED)); } return; } From 145d2c86fb4a23d076dd7326fe0ea9af4e95335a Mon Sep 17 00:00:00 2001 From: AndrewFG Date: Wed, 30 Oct 2024 12:12:08 +0000 Subject: [PATCH 4/5] tweaks and refactoring Signed-off-by: AndrewFG --- .../openhab/binding/zigbee/ZigBeeBindingConstants.java | 4 ++-- ...eAbs.java => ZigBeeConverterColorTempAbsolute.java} | 10 +++++----- .../converter/ZigBeeConverterColorTemperature.java | 3 --- .../ZigBeeDefaultChannelConverterProvider.java | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) rename org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/{ZigBeeConverterColorTemperatureAbs.java => ZigBeeConverterColorTempAbsolute.java} (92%) 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 9dfcc9219..714b52fd4 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 @@ -58,8 +58,8 @@ public class ZigBeeBindingConstants { public static final String CHANNEL_LABEL_COLOR_TEMPERATURE = "Color Temperature"; public static final ChannelTypeUID CHANNEL_COLOR_TEMPERATURE = SYSTEM_COLOR_TEMPERATURE.getUID(); - public static final String CHANNEL_NAME_COLOR_TEMPERATURE_ABS = "colortemperature_abs"; - public static final ChannelTypeUID CHANNEL_COLOR_TEMPERATURE_ABS = SYSTEM_COLOR_TEMPERATURE_ABS.getUID(); + public static final String CHANNEL_NAME_COLOR_TEMP_ABSOLUTE = "colortempabsolute"; + public static final ChannelTypeUID CHANNEL_COLOR_TEMP_ABSOLUTE = SYSTEM_COLOR_TEMPERATURE_ABS.getUID(); public static final String CHANNEL_NAME_ILLUMINANCE_VALUE = "illuminance"; public static final String CHANNEL_LABEL_ILLUMINANCE_VALUE = "Illuminance"; diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTempAbsolute.java similarity index 92% rename from org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java rename to org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTempAbsolute.java index f9933b158..e6bf6dd5f 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureAbs.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTempAbsolute.java @@ -38,9 +38,9 @@ * * @author Andrew Fiddian-Green - Initial Contribution */ -public class ZigBeeConverterColorTemperatureAbs extends ZigBeeConverterColorTemperature { +public class ZigBeeConverterColorTempAbsolute extends ZigBeeConverterColorTemperature { - private Logger logger = LoggerFactory.getLogger(ZigBeeConverterColorTemperatureAbs.class); + private Logger logger = LoggerFactory.getLogger(ZigBeeConverterColorTempAbsolute.class); @Override public boolean initializeConverter(ZigBeeThingHandler thing) { @@ -71,9 +71,9 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { return super.getChannel(thingUID, endpoint) == null ? null : ChannelBuilder .create(createChannelUID(thingUID, endpoint, - ZigBeeBindingConstants.CHANNEL_NAME_COLOR_TEMPERATURE_ABS), + ZigBeeBindingConstants.CHANNEL_NAME_COLOR_TEMP_ABSOLUTE), ZigBeeBindingConstants.ITEM_TYPE_NUMBER_TEMPERATURE) - .withType(ZigBeeBindingConstants.CHANNEL_COLOR_TEMPERATURE_ABS) + .withType(ZigBeeBindingConstants.CHANNEL_COLOR_TEMP_ABSOLUTE) .withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_COLOR_TEMPERATURE) .withProperties(createProperties(endpoint)).build(); } @@ -82,7 +82,7 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { public void attributeUpdated(ZclAttribute attribute, Object val) { if (attribute.getClusterType() == ZclClusterType.COLOR_CONTROL && attribute.getId() == ZclColorControlCluster.ATTR_COLORTEMPERATURE) { - logger.debug("{}: ZigBee attribute reports {} on endpoint {}", endpoint.getIeeeAddress(), attribute, + logger.debug("{}: ZigBee attribute reports {} on endpoint {}", endpoint.getIeeeAddress(), attribute, endpoint.getEndpointId()); if (val instanceof Integer mired) { updateChannelState(QuantityType.valueOf(mired, Units.MIRED)); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java index 1083acc80..9db51d501 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java @@ -57,7 +57,6 @@ public class ZigBeeConverterColorTemperature extends ZigBeeBaseChannelConverter protected double kelvinMin; protected double kelvinMax; - private double kelvinRange; // Default range of 2000K to 6500K private final Integer DEFAULT_MIN_TEMPERATURE_IN_KELVIN = 2000; @@ -268,8 +267,6 @@ private void determineMinMaxTemperature(ZclColorControlCluster serverClusterColo } else { kelvinMax = miredToKelvin(minTemperatureInMired); } - - kelvinRange = kelvinMax - kelvinMin; } /** diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeDefaultChannelConverterProvider.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeDefaultChannelConverterProvider.java index cbdb5101b..ce9756208 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeDefaultChannelConverterProvider.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeDefaultChannelConverterProvider.java @@ -39,7 +39,7 @@ public ZigBeeDefaultChannelConverterProvider() { // Add all the converters into the map... channelMap.put(ZigBeeBindingConstants.CHANNEL_COLOR_COLOR, ZigBeeConverterColorColor.class); channelMap.put(ZigBeeBindingConstants.CHANNEL_COLOR_TEMPERATURE, ZigBeeConverterColorTemperature.class); - channelMap.put(ZigBeeBindingConstants.CHANNEL_COLOR_TEMPERATURE_ABS, ZigBeeConverterColorTemperatureAbs.class); + channelMap.put(ZigBeeBindingConstants.CHANNEL_COLOR_TEMP_ABSOLUTE, ZigBeeConverterColorTempAbsolute.class); channelMap.put(ZigBeeBindingConstants.CHANNEL_DOORLOCK_STATE, ZigBeeConverterDoorLock.class); channelMap.put(ZigBeeBindingConstants.CHANNEL_ELECTRICAL_ACTIVEPOWER, ZigBeeConverterMeasurementPower.class); channelMap.put(ZigBeeBindingConstants.CHANNEL_HUMIDITY_VALUE, ZigBeeConverterRelativeHumidity.class); From 1ec3dd073c6e4f654ee8dd4e5a72b7194a012d51 Mon Sep 17 00:00:00 2001 From: AndrewFG Date: Wed, 30 Oct 2024 15:14:52 +0000 Subject: [PATCH 5/5] fix channel type id; add documentation Signed-off-by: AndrewFG --- org.openhab.binding.zigbee/README.md | 10 ++++++---- .../openhab/binding/zigbee/ZigBeeBindingConstants.java | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/org.openhab.binding.zigbee/README.md b/org.openhab.binding.zigbee/README.md index 5da806313..0eae505b1 100644 --- a/org.openhab.binding.zigbee/README.md +++ b/org.openhab.binding.zigbee/README.md @@ -384,20 +384,22 @@ A set of channels will be created depending on what clusters and endpoints a dev The following channels are supported -: -| Channel UID | ZigBee Cluster | Type | Description | +| Channel Type ID | ZigBee Cluster | Type | Description | | ---------------------------- | ---------------------------------------- | ------------------------ | ----------- | | battery-level | `POWER_CONFIGURATION` (0x0001) | Number | | | battery_voltage | `POWER_CONFIGURATION` (0x0001) | Number:ElectricPotential | | | binaryinput | `BINARY_INPUT__BASIC` (0x000F) | Switch | | | color_color | `COLOR_CONTROL` (0x0300) | Color | | -| color_temperature | `COLOR_CONTROL` (0x0300) | Dimmer | | +| color-temperature | `COLOR_CONTROL` (0x0300) | Dimmer | Percent | +| color-temperature-abs | `COLOR_CONTROL` (0x0300) | Number:Temperature | Absolute | | door_state | `DOOR_LOCK` (0x0101) | Switch | | | electrical_activepower | `ELECTRICAL_MEASUREMENT` (0x0B04) | Number:Power | | | electrical_rmscurrent | `ELECTRICAL_MEASUREMENT` (0x0B04) | Number:ElectricCurrent | | | electrical_rmsvoltage | `ELECTRICAL_MEASUREMENT` (0x0B04) | Number:ElectricPotential | | | fancontrol | `FAN_CONTROL` (0x0202) | Number | | -| ias_codetector | `IAS_ZONE` (0x0500) | Switch | | +| ias_cosensor | `IAS_ZONE` (0x0500) | Switch | | | ias_contactportal1 | `IAS_ZONE` (0x0500) | Switch | | +| ias_contactportal2 | `IAS_ZONE` (0x0500) | Switch | | | ias_fire | `IAS_ZONE` (0x0500) | Switch | | | ias_motionintrusion | `IAS_ZONE` (0x0500) | Switch | | | ias_motionpresence | `IAS_ZONE` (0x0500) | Switch | | @@ -406,7 +408,7 @@ The following channels are supported -: | ias_movement | `IAS_ZONE` (0x0500) | Switch | | | ias_vibration | `IAS_ZONE` (0x0500) | Switch | | | ias_tamper | `IAS_ZONE` (0x0500) | Switch | | -| ias_tamper | `IAS_ZONE` (0x0500) | Switch | | +| low-battery | `POWER_CONFIGURATION` (0x0001) | Switch | | | measurement_illuminance | `ILLUMINANCE_MEASUREMENT` (0x0400) | Number | | | measurement_pressure | `PRESSURE_MEASUREMENT` (0x0403) | Number:Pressure | | | measurement_relativehumidity | `RELATIVE_HUMIDITY_MEASUREMENT` (0x0405) | 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 714b52fd4..08ece6f24 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 @@ -150,7 +150,7 @@ public class ZigBeeBindingConstants { public static final String CHANNEL_NAME_POWER_BATTERYPERCENT = "batterylevel"; public static final String CHANNEL_LABEL_POWER_BATTERYPERCENT = "Battery Level"; - public static final ChannelTypeUID CHANNEL_POWER_BATTERYPERCENT = new ChannelTypeUID("system:battery-level"); + public static final ChannelTypeUID CHANNEL_POWER_BATTERYPERCENT = SYSTEM_CHANNEL_BATTERY_LEVEL.getUID(); public static final String CHANNEL_NAME_POWER_BATTERYVOLTAGE = "batteryvoltage"; public static final String CHANNEL_LABEL_POWER_BATTERYVOLTAGE = "Battery Voltage";