From a4f3772c22503b1f990ccf04278f2a4ef5f09962 Mon Sep 17 00:00:00 2001 From: Chris Jackson Date: Sat, 25 Sep 2021 15:04:25 +1200 Subject: [PATCH 1/3] Refactor Tuya into separate bundle Signed-off-by: Chris Jackson (+4 squashed commits) Squashed commits: [8c397c9] Add tests for ZigBeeConverterTuyaButton Signed-off-by: Daniel Schall [d68a96a] Fix build break Signed-off-by: Daniel Schall [9a37f0e] Add Tuya button support Signed-off-by: Daniel Schall [af45e77] Create Tuya specific handler binding Signed-off-by: Chris Jackson --- bom/pom.xml | 7 +- feature/pom.xml | 15 +- org.openhab.binding.zigbee.tuya/.gitignore | 1 + org.openhab.binding.zigbee.tuya/NOTICE | 14 ++ org.openhab.binding.zigbee.tuya/pom.xml | 24 ++ .../zigbee/tuya/TuyaBindingConstants.java | 33 +++ .../converter/ZigBeeConverterTuyaButton.java | 216 ++++++++++++++++++ .../ZigBeeTuyaChannelConverterProvider.java | 45 ++++ .../tuya/internal/TuyaButtonPressCommand.java | 84 +++++++ .../ZigBeeTuyaDiscoveryParticipant.java | 66 ++++++ .../src/main/resources/OH-INF/discovery.txt | 4 + .../resources/OH-INF/thing/tuya/ts0041.xml | 55 +++++ .../resources/OH-INF/thing/tuya/ts0042.xml | 62 +++++ .../resources/OH-INF/thing/tuya/ts0043.xml | 69 ++++++ .../resources/OH-INF/thing/tuya/ts0044.xml | 76 ++++++ .../ZigBeeConverterTuyaButtonTest.java | 188 +++++++++++++++ .../main/resources/OH-INF/thing/channels.xml | 13 ++ pom.xml | 1 + 18 files changed, 967 insertions(+), 6 deletions(-) create mode 100644 org.openhab.binding.zigbee.tuya/.gitignore create mode 100644 org.openhab.binding.zigbee.tuya/NOTICE create mode 100644 org.openhab.binding.zigbee.tuya/pom.xml create mode 100644 org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/TuyaBindingConstants.java create mode 100644 org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButton.java create mode 100644 org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeTuyaChannelConverterProvider.java create mode 100644 org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaButtonPressCommand.java create mode 100644 org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/discovery/ZigBeeTuyaDiscoveryParticipant.java create mode 100644 org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/discovery.txt create mode 100644 org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0041.xml create mode 100644 org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0042.xml create mode 100644 org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0043.xml create mode 100644 org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0044.xml create mode 100644 org.openhab.binding.zigbee.tuya/src/test/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButtonTest.java diff --git a/bom/pom.xml b/bom/pom.xml index 6ce6c1a60..4b322f51c 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -12,7 +12,7 @@ org.openhab.addons.bom.zigbee pom - openHAB ZigBee :: BOM :: openHAB ZigBee Binding + openHAB Add-ons :: Bundles :: ZigBee Binding BOM @@ -50,6 +50,11 @@ org.openhab.binding.zigbee.telegesis ${project.version} + + org.openhab.addons.bundles + org.openhab.binding.zigbee.tuya + ${project.version} + org.openhab.addons.bundles org.openhab.binding.zigbee.xbee diff --git a/feature/pom.xml b/feature/pom.xml index ee2f0336a..d082411ce 100644 --- a/feature/pom.xml +++ b/feature/pom.xml @@ -45,11 +45,16 @@ org.openhab.binding.zigbee.ember ${project.version} - - org.openhab.addons.bundles - org.openhab.binding.zigbee.telegesis - ${project.version} - + + org.openhab.addons.bundles + org.openhab.binding.zigbee.telegesis + ${project.version} + + + org.openhab.addons.bundles + org.openhab.binding.zigbee.tuya + ${project.version} + org.openhab.addons.bundles org.openhab.binding.zigbee.xbee diff --git a/org.openhab.binding.zigbee.tuya/.gitignore b/org.openhab.binding.zigbee.tuya/.gitignore new file mode 100644 index 000000000..ae3c17260 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/org.openhab.binding.zigbee.tuya/NOTICE b/org.openhab.binding.zigbee.tuya/NOTICE new file mode 100644 index 000000000..705b3bdad --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/NOTICE @@ -0,0 +1,14 @@ +This content is produced and maintained by the openHAB project. + +* Project home: https://www.openhab.org + +== Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0/. + +== Source Code + +https://github.com/openhab/org.openhab.binding.zigbee + diff --git a/org.openhab.binding.zigbee.tuya/pom.xml b/org.openhab.binding.zigbee.tuya/pom.xml new file mode 100644 index 000000000..6c61c3776 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + + org.openhab.addons.bundles + org.openhab.addons.zigbee.reactor + 3.2.0-SNAPSHOT + + + org.openhab.binding.zigbee.tuya + + openHAB Add-ons :: Bundles :: ZigBee Tuya Handler + + + + org.openhab.addons.bundles + org.openhab.binding.zigbee + ${project.version} + provided + + + + diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/TuyaBindingConstants.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/TuyaBindingConstants.java new file mode 100644 index 000000000..30edaa3f8 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/TuyaBindingConstants.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2010-2021 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.tuya; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.thing.type.ChannelTypeUID; + +/** + * The {@link TuyaBindingConstants} class defines common constants, which are + * used across the whole binding. + * + * @author Chris Jackson - Initial contribution + */ +@NonNullByDefault +public class TuyaBindingConstants { + + public static final String BINDING_ID = "zigbee"; + + public static final String CHANNEL_NAME_TUYA_BUTTON = "tuyabutton"; + public static final String CHANNEL_LABEL_TUYA_BUTTON = "Button"; + public static final ChannelTypeUID CHANNEL_TUYA_BUTTON = new ChannelTypeUID("zigbee:tuya_button"); + +} diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButton.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButton.java new file mode 100644 index 000000000..40778c4e4 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButton.java @@ -0,0 +1,216 @@ +/** + * Copyright (c) 2010-2021 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.tuya.converter; + +import static java.lang.Integer.*; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Set; +import java.util.concurrent.ExecutionException; + +import org.openhab.core.thing.Channel; +import org.openhab.core.thing.CommonTriggerEvents; +import org.openhab.core.thing.ThingUID; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; +import org.openhab.binding.zigbee.tuya.internal.TuyaButtonPressCommand; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.zsmartsystems.zigbee.CommandResult; +import com.zsmartsystems.zigbee.ZigBeeEndpoint; +import com.zsmartsystems.zigbee.zcl.ZclAttribute; +import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; +import com.zsmartsystems.zigbee.zcl.ZclCluster; +import com.zsmartsystems.zigbee.zcl.ZclCommand; +import com.zsmartsystems.zigbee.zcl.ZclCommandListener; +import com.zsmartsystems.zigbee.zcl.ZclStatus; +import com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster; + +/** + * Generic converter for Tuya buttons (e.g., Zemismart). + *

+ * This converter is handling the Tuya-specific command (ID: 253) and emits button-pressed events. + *

+ * As the configuration is done via channel properties, this converter is usable via static thing types only. + * + * @author Daniel Schall - initial contribution + */ +public class ZigBeeConverterTuyaButton extends ZigBeeBaseChannelConverter + implements ZclAttributeListener, ZclCommandListener { + + private Logger logger = LoggerFactory.getLogger(ZigBeeConverterTuyaButton.class); + + private ZclCluster clientCluster = null; + private ZclCluster serverCluster = null; + + // Tuya devices sometimes send duplicate commands with the same tx id. + // We keep track of the last received Tx id and ignore the duplicate. + private Integer lastTxId = -1; + + @Override + public Set getImplementedClientClusters() { + return Collections.singleton(ZclOnOffCluster.CLUSTER_ID); + } + + @Override + public Set getImplementedServerClusters() { + return Collections.singleton(ZclOnOffCluster.CLUSTER_ID); + } + + @Override + public boolean initializeDevice() { + ZclCluster clientCluster = endpoint.getOutputCluster(ZclOnOffCluster.CLUSTER_ID); + ZclCluster serverCluster = endpoint.getInputCluster(ZclOnOffCluster.CLUSTER_ID); + + if (clientCluster == null) { + logger.error("{}: Error opening client cluster {} on endpoint {}", endpoint.getIeeeAddress(), + ZclOnOffCluster.CLUSTER_ID, endpoint.getEndpointId()); + return false; + } + + if (serverCluster == null) { + logger.error("{}: Error opening server cluster {} on endpoint {}", endpoint.getIeeeAddress(), + ZclOnOffCluster.CLUSTER_ID, endpoint.getEndpointId()); + return false; + } + + ZclReportingConfig reporting = new ZclReportingConfig(channel); + + try { + CommandResult bindResponse = bind(serverCluster).get(); + if (bindResponse.isSuccess()) { + // Configure reporting + ZclAttribute attribute = serverCluster.getAttribute(ZclOnOffCluster.ATTR_ONOFF); + CommandResult reportingResponse = attribute + .setReporting(reporting.getReportingTimeMin(), reporting.getReportingTimeMax()).get(); + handleReportingResponse(reportingResponse, POLLING_PERIOD_HIGH, reporting.getPollingPeriod()); + } else { + logger.debug("{}: Error 0x{} setting server binding", endpoint.getIeeeAddress(), + Integer.toHexString(bindResponse.getStatusCode())); + pollingPeriod = POLLING_PERIOD_HIGH; + } + + } catch (InterruptedException | ExecutionException e) { + logger.error("{}: Exception setting reporting ", endpoint.getIeeeAddress(), e); + } + + try { + CommandResult bindResponse = bind(clientCluster).get(); + if (!bindResponse.isSuccess()) { + logger.error("{}: Error 0x{} setting client binding for cluster {}", endpoint.getIeeeAddress(), + toHexString(bindResponse.getStatusCode()), ZclOnOffCluster.CLUSTER_ID); + } + } catch (InterruptedException | ExecutionException e) { + logger.error("{}: Exception setting client binding to cluster {}: {}", endpoint.getIeeeAddress(), + ZclOnOffCluster.CLUSTER_ID, e); + } + + return true; + } + + @Override + public synchronized boolean initializeConverter(ZigBeeThingHandler thing) { + super.initializeConverter(thing); + + clientCluster = endpoint.getOutputCluster(ZclOnOffCluster.CLUSTER_ID); + serverCluster = endpoint.getInputCluster(ZclOnOffCluster.CLUSTER_ID); + + if (clientCluster == null) { + logger.error("{}: Error opening device client controls", endpoint.getIeeeAddress()); + return false; + } + + if (serverCluster == null) { + logger.error("{}: Error opening device server controls", endpoint.getIeeeAddress()); + return false; + } + + clientCluster.addCommandListener(this); + serverCluster.addAttributeListener(this); + + // Add Tuya-specific command + // + HashMap> commandMap = new HashMap<>(); + commandMap.put(TuyaButtonPressCommand.COMMAND_ID, TuyaButtonPressCommand.class); + clientCluster.addClientCommands(commandMap); + + return true; + } + + @Override + public void disposeConverter() { + if(clientCluster != null) { + clientCluster.removeCommandListener(this); + } + if (serverCluster != null) { + serverCluster.removeAttributeListener(this); + } + } + + @Override + public void handleRefresh() { + // nothing to do, as we only listen to commands + } + + @Override + public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { + // This converter is used only for channels specified in static thing types, and cannot be used to construct + // channels based on an endpoint alone. + return null; + } + + @Override + public boolean commandReceived(ZclCommand command) { + logger.debug("{} received command {}", endpoint.getIeeeAddress(), command); + Integer thisTxId = command.getTransactionId(); + if(lastTxId == thisTxId) + { + logger.debug("{} ignoring duplicate command {}", endpoint.getIeeeAddress(), thisTxId); + } + else if (command instanceof TuyaButtonPressCommand) { + TuyaButtonPressCommand tuyaButtonPressCommand = (TuyaButtonPressCommand) command; + thing.triggerChannel(channel.getUID(), getEventType(tuyaButtonPressCommand.getPressType())); + clientCluster.sendDefaultResponse(command, ZclStatus.SUCCESS); + } + else { + logger.warn("{} received unknown command {}", endpoint.getIeeeAddress(), command); + } + + lastTxId = thisTxId; + return true; + } + + @Override + public void attributeUpdated(ZclAttribute attribute, Object val) { + logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute); + } + + private String getEventType(Integer pressType) + { + switch(pressType) + { + case 0: + return CommonTriggerEvents.SHORT_PRESSED; + case 1: + return CommonTriggerEvents.DOUBLE_PRESSED; + case 2: + return CommonTriggerEvents.LONG_PRESSED; + default: + logger.warn("{} received unknown pressType {}", endpoint.getIeeeAddress(), pressType); + return CommonTriggerEvents.SHORT_PRESSED; + } + } +} diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeTuyaChannelConverterProvider.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeTuyaChannelConverterProvider.java new file mode 100644 index 000000000..d43df6e61 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeTuyaChannelConverterProvider.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2010-2021 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.tuya.converter; + +import java.util.HashMap; +import java.util.Map; + +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory; +import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterProvider; +import org.openhab.core.thing.type.ChannelTypeUID; +import org.osgi.service.component.annotations.Component; + +/** + * The base {@link ZigBeeTuyaChannelConverterProvider} of the binding making the Tuya specific + * {@link ZigBeeBaseChannelConverter}s available for the {@link ZigBeeChannelConverterFactory}. + * + * @author Chris Jackson - Initial contribution + */ +@Component(immediate = true, service = ZigBeeChannelConverterProvider.class) +public final class ZigBeeTuyaChannelConverterProvider implements ZigBeeChannelConverterProvider { + + private final Map> channelMap = new HashMap<>(); + + public ZigBeeTuyaChannelConverterProvider() { + // Add all the converters into the map... + channelMap.put(ZigBeeBindingConstants.CHANNEL_COLOR_COLOR, ZigBeeConverterTuyaButton.class); + } + + @Override + public Map> getChannelConverters() { + return channelMap; + } +} diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaButtonPressCommand.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaButtonPressCommand.java new file mode 100644 index 000000000..0d80c2da3 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaButtonPressCommand.java @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2010-2021 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.tuya.internal; + +import com.zsmartsystems.zigbee.zcl.ZclCommand; +import com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer; +import com.zsmartsystems.zigbee.zcl.ZclFieldSerializer; +import com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster; +import com.zsmartsystems.zigbee.zcl.protocol.ZclCommandDirection; +import com.zsmartsystems.zigbee.zcl.protocol.ZclDataType; + +/** + * Manufacturer specific command for the Tuya button + * + * @author Daniel Schall - initial contribution + * + */ +public class TuyaButtonPressCommand extends ZclCommand { + /** + * The command ID. + */ + public static int COMMAND_ID = 0xFD; + + /** + * Type of button press. + *

+ * 0 = short press + * 1 = double press + * 2 = long press + */ + private Integer pressType; + + /** + * Default constructor. + * + */ + public TuyaButtonPressCommand() { + clusterId = ZclOnOffCluster.CLUSTER_ID; + commandId = COMMAND_ID; + genericCommand = false; + commandDirection = ZclCommandDirection.CLIENT_TO_SERVER; + } + + public TuyaButtonPressCommand(Integer pressType) { + this(); + this.pressType = pressType; + } + + public Integer getPressType() { + return pressType; + } + + @Override + public void serialize(ZclFieldSerializer serializer) { + serializer.serialize(pressType, ZclDataType.UNSIGNED_8_BIT_INTEGER); + } + + @Override + public void deserialize(final ZclFieldDeserializer deserializer) { + pressType = (Integer) deserializer.deserialize(ZclDataType.UNSIGNED_8_BIT_INTEGER); + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(113); + builder.append(this.getClass().getSimpleName()); + builder.append(" ["); + builder.append(super.toString()); + builder.append(", pressType="); + builder.append(pressType); + builder.append(']'); + return builder.toString(); + } +} diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/discovery/ZigBeeTuyaDiscoveryParticipant.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/discovery/ZigBeeTuyaDiscoveryParticipant.java new file mode 100644 index 000000000..68ea2d4d2 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/discovery/ZigBeeTuyaDiscoveryParticipant.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2010-2021 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.tuya.internal.discovery; + +import java.util.Map; +import java.util.Set; + +import org.openhab.binding.zigbee.discovery.ZigBeeDiscoveryParticipant; +import org.openhab.binding.zigbee.internal.ZigBeeThingTypeMatcher; +import org.openhab.core.config.discovery.DiscoveryResult; +import org.openhab.core.config.discovery.DiscoveryResultBuilder; +import org.openhab.core.thing.Thing; +import org.openhab.core.thing.ThingTypeUID; +import org.openhab.core.thing.ThingUID; +import org.osgi.service.component.annotations.Component; + +import com.zsmartsystems.zigbee.ZigBeeNode; + +/** + * The Tuya ZigBee discovery participant + * + * @author Chris Jackson + * + */ +@Component(immediate = true) +public class ZigBeeTuyaDiscoveryParticipant implements ZigBeeDiscoveryParticipant { + + private final ZigBeeThingTypeMatcher matcher = new ZigBeeThingTypeMatcher(); + + @Override + public Set getSupportedThingTypeUIDs() { + return matcher.getSupportedThingTypeUIDs(); + } + + @Override + public DiscoveryResult createResult(ThingUID bridgeUID, ZigBeeNode node, Map properties) { + ThingTypeUID thingTypeUID = matcher.matchThingType(properties); + if (thingTypeUID == null) { + return null; + } + + ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, + node.getIeeeAddress().toString().toLowerCase().replaceAll("[^a-z0-9_/]", "")); + + String label; + // If we know the manufacturer and model, then give this device a name + if ((properties.get(Thing.PROPERTY_VENDOR) != null) && (properties.get(Thing.PROPERTY_MODEL_ID) != null)) { + label = properties.get(Thing.PROPERTY_VENDOR) + " " + properties.get(Thing.PROPERTY_MODEL_ID); + } else { + label = "Unknown ZigBee Device"; + } + + return DiscoveryResultBuilder.create(thingUID).withThingType(thingTypeUID).withProperties(properties) + .withBridge(bridgeUID).withLabel(label).build(); + } +} diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/discovery.txt b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/discovery.txt new file mode 100644 index 000000000..d4fef60fa --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/discovery.txt @@ -0,0 +1,4 @@ +tuya_ts0041,vendor=_TZ3000_tk3s5tyg,modelId=TS0041 +tuya_ts0042,vendor=_TZ3000_adkvzooy,modelId=TS0042 +tuya_ts0043,vendor=_TZ3000_qzjcsmar,modelId=TS0043 +tuya_ts0044,vendor=_TZ3000_vp6clf9d,modelId=TS0044 diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0041.xml b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0041.xml new file mode 100644 index 000000000..03ba99c98 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0041.xml @@ -0,0 +1,55 @@ + + + + + + Generic Tuya 1-Button Wall Switch + WallSwitch + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + + 1 + + + + + + + Tuya + TS0041 + END_DEVICE + + + zigbee_macaddress + + + + + + + + \ No newline at end of file diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0042.xml b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0042.xml new file mode 100644 index 000000000..4d4be2664 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0042.xml @@ -0,0 +1,62 @@ + + + + + + Generic Tuya 2-Button Wall Switch + WallSwitch + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + + 1 + + + + + + + 2 + + + + + + + Tuya + TS0042 + END_DEVICE + + + zigbee_macaddress + + + + + + + + \ No newline at end of file diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0043.xml b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0043.xml new file mode 100644 index 000000000..51166fe8e --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0043.xml @@ -0,0 +1,69 @@ + + + + + + Generic Tuya 3-Button Wall Switch + WallSwitch + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + + 1 + + + + + + + 2 + + + + + + + 3 + + + + + + + Tuya + TS0043 + END_DEVICE + + + zigbee_macaddress + + + + + + + + \ No newline at end of file diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0044.xml b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0044.xml new file mode 100644 index 000000000..fd43b18d1 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0044.xml @@ -0,0 +1,76 @@ + + + + + + Generic Tuya 4-Button Wall Switch + WallSwitch + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + + 1 + + + + + + + 2 + + + + + + + 3 + + + + + + + 4 + + + + + + + Tuya + TS0044 + END_DEVICE + + + zigbee_macaddress + + + + + + + + \ No newline at end of file diff --git a/org.openhab.binding.zigbee.tuya/src/test/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButtonTest.java b/org.openhab.binding.zigbee.tuya/src/test/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButtonTest.java new file mode 100644 index 000000000..99562a45c --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/test/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButtonTest.java @@ -0,0 +1,188 @@ +/** + * Copyright (c) 2010-2021 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.tuya.converter; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentMatchers; +import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; +import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.tuya.internal.TuyaButtonPressCommand; +import org.openhab.core.thing.Channel; +import org.openhab.core.thing.CommonTriggerEvents; + +import com.zsmartsystems.zigbee.CommandResult; +import com.zsmartsystems.zigbee.IeeeAddress; +import com.zsmartsystems.zigbee.ZigBeeCommand; +import com.zsmartsystems.zigbee.ZigBeeEndpoint; +import com.zsmartsystems.zigbee.ZigBeeProfileType; +import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; +import com.zsmartsystems.zigbee.zcl.ZclCluster; +import com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster; + +/** + * Unit tests for the {@link ZigBeeConverterTuyaButtonTest}. + * + * @author Daniel Schall - initial controbution. + */ +public class ZigBeeConverterTuyaButtonTest { + + private ZigBeeConverterTuyaButton converter; + + private ZigBeeThingHandler thingHandler; + private Channel channel; + private ZigBeeCoordinatorHandler coordinatorHandler; + private ZigBeeEndpoint endpoint; + + private Map channelProperties; + + @BeforeEach + public void setup() { + IeeeAddress ieeeAddress = new IeeeAddress(); + int endpointId = 1; + + endpoint = mock(ZigBeeEndpoint.class); + thingHandler = mock(ZigBeeThingHandler.class); + + channel = mock(Channel.class); + channelProperties = new HashMap<>(); + when(channel.getProperties()).thenReturn(channelProperties); + + coordinatorHandler = mock(ZigBeeCoordinatorHandler.class); + when(coordinatorHandler.getEndpoint(ieeeAddress, endpointId)).thenReturn(endpoint); + when(coordinatorHandler.getLocalIeeeAddress()).thenReturn(ieeeAddress); + when(coordinatorHandler.getLocalEndpointId(ArgumentMatchers.any(ZigBeeProfileType.class))).thenReturn(1); + + converter = new ZigBeeConverterTuyaButton(); + converter.initialize(channel, coordinatorHandler, ieeeAddress, endpointId); + } + + @Test + public void testBasicInitialization() { + ZclCluster cluster = mockCluster(ZclOnOffCluster.CLUSTER_ID); + boolean initResult = converter.initializeConverter(thingHandler); + + assertTrue(initResult); + verify(cluster, times(1)).addCommandListener(converter); + verify(cluster, times(1)).addAttributeListener(any(ZclAttributeListener.class)); + } + + @Test + public void testDisposalRemvoesListeners() { + ZclCluster cluster = mockCluster(ZclOnOffCluster.CLUSTER_ID); + converter.initializeConverter(thingHandler); + converter.disposeConverter(); + + verify(cluster, times(1)).addCommandListener(converter); + verify(cluster, times(1)).addAttributeListener(any(ZclAttributeListener.class)); + verify(cluster, times(1)).removeCommandListener(converter); + verify(cluster, times(1)).removeAttributeListener(any(ZclAttributeListener.class)); + } + + @Test + public void testCommandHandlerInstallation() { + ZclCluster cluster = mockCluster(ZclOnOffCluster.CLUSTER_ID); + converter.initializeConverter(thingHandler); + + verify(cluster, times(1)).addClientCommands(any(Map.class)); + } + + @Test + public void testShortPressCommand() { + mockCluster(ZclOnOffCluster.CLUSTER_ID); + converter.initializeConverter(thingHandler); + + TuyaButtonPressCommand tuyaButtonPressCommand = new TuyaButtonPressCommand(0); + tuyaButtonPressCommand.setTransactionId(1); + converter.commandReceived(tuyaButtonPressCommand); + + verify(thingHandler, times(1)).triggerChannel(channel.getUID(), CommonTriggerEvents.SHORT_PRESSED); + verify(thingHandler, times(0)).triggerChannel(channel.getUID(), CommonTriggerEvents.DOUBLE_PRESSED); + verify(thingHandler, times(0)).triggerChannel(channel.getUID(), CommonTriggerEvents.LONG_PRESSED); + } + + @Test + public void testDoublePressCommand() { + mockCluster(ZclOnOffCluster.CLUSTER_ID); + converter.initializeConverter(thingHandler); + + TuyaButtonPressCommand tuyaButtonPressCommand = new TuyaButtonPressCommand(1); + tuyaButtonPressCommand.setTransactionId(1); + converter.commandReceived(tuyaButtonPressCommand); + + verify(thingHandler, times(0)).triggerChannel(channel.getUID(), CommonTriggerEvents.SHORT_PRESSED); + verify(thingHandler, times(1)).triggerChannel(channel.getUID(), CommonTriggerEvents.DOUBLE_PRESSED); + verify(thingHandler, times(0)).triggerChannel(channel.getUID(), CommonTriggerEvents.LONG_PRESSED); + } + + @Test + public void testLongPressCommand() { + mockCluster(ZclOnOffCluster.CLUSTER_ID); + converter.initializeConverter(thingHandler); + + TuyaButtonPressCommand tuyaButtonPressCommand = new TuyaButtonPressCommand(2); + tuyaButtonPressCommand.setTransactionId(1); + converter.commandReceived(tuyaButtonPressCommand); + + verify(thingHandler, times(0)).triggerChannel(channel.getUID(), CommonTriggerEvents.SHORT_PRESSED); + verify(thingHandler, times(0)).triggerChannel(channel.getUID(), CommonTriggerEvents.DOUBLE_PRESSED); + verify(thingHandler, times(1)).triggerChannel(channel.getUID(), CommonTriggerEvents.LONG_PRESSED); + } + + @Test + public void testTwoCommands() { + mockCluster(ZclOnOffCluster.CLUSTER_ID); + converter.initializeConverter(thingHandler); + + TuyaButtonPressCommand tuyaButtonPressCommand = new TuyaButtonPressCommand(0); + tuyaButtonPressCommand.setTransactionId(1); + converter.commandReceived(tuyaButtonPressCommand); + tuyaButtonPressCommand.setTransactionId(2); + converter.commandReceived(tuyaButtonPressCommand); + + verify(thingHandler, times(2)).triggerChannel(channel.getUID(), CommonTriggerEvents.SHORT_PRESSED); + } + + @Test + public void testDuplicateTransactionCommand() { + mockCluster(ZclOnOffCluster.CLUSTER_ID); + converter.initializeConverter(thingHandler); + + TuyaButtonPressCommand tuyaButtonPressCommand = new TuyaButtonPressCommand(0); + tuyaButtonPressCommand.setTransactionId(1); + converter.commandReceived(tuyaButtonPressCommand); + converter.commandReceived(tuyaButtonPressCommand); + + verify(thingHandler, times(1)).triggerChannel(channel.getUID(), CommonTriggerEvents.SHORT_PRESSED); + verify(thingHandler, times(0)).triggerChannel(channel.getUID(), CommonTriggerEvents.DOUBLE_PRESSED); + verify(thingHandler, times(0)).triggerChannel(channel.getUID(), CommonTriggerEvents.LONG_PRESSED); + } + + private ZclCluster mockCluster(int clusterId) { + ZclCluster cluster = mock(ZclCluster.class); + when(cluster.getClusterId()).thenReturn(clusterId); + when(cluster.bind(ArgumentMatchers.any(IeeeAddress.class), ArgumentMatchers.anyInt())) + .thenReturn(CompletableFuture.completedFuture(new CommandResult(new ZigBeeCommand()))); + when(endpoint.getOutputCluster(clusterId)).thenReturn(cluster); + when(endpoint.getInputCluster(clusterId)).thenReturn(cluster); + return cluster; + } +} 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 e453f2858..be3f24cd9 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 @@ -419,5 +419,18 @@ Blinds + + + trigger + + Emits events when button is pressed + + + + + + + + diff --git a/pom.xml b/pom.xml index c1e639083..728d1d2d4 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,7 @@ org.openhab.binding.zigbee.cc2531 org.openhab.binding.zigbee.ember org.openhab.binding.zigbee.telegesis + org.openhab.binding.zigbee.tuya org.openhab.binding.zigbee.xbee org.openhab.binding.zigbee.console org.openhab.binding.zigbee.console.ember From b4fd66b405eacfddb5df3cf7511184feb677579d Mon Sep 17 00:00:00 2001 From: Chris Jackson Date: Sun, 24 Oct 2021 09:33:53 +1300 Subject: [PATCH 2/3] Move Tuya channel definition into Tuya bundle Signed-off-by: Chris Jackson --- .../main/resources/OH-INF/thing/channels.xml | 436 ++++++++++++++++++ .../main/resources/OH-INF/thing/channels.xml | 14 - 2 files changed, 436 insertions(+), 14 deletions(-) create mode 100644 org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/channels.xml diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/channels.xml b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/channels.xml new file mode 100644 index 000000000..be3f24cd9 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/channels.xml @@ -0,0 +1,436 @@ + + + + + + Number:ElectricPotential + + The current battery voltage + Energy + + + + + + String + + The battery alarm state + Energy + + + + + + + + + + + + + + Color + + The color channel allows to control the color of a light. + It is also possible to dim values and switch the light on and off. + + ColorLight + veto + + + + + Switch + + Locks and unlocks the door and maintains the lock state + Door + veto + + + + + Number + + Set the fan mode + HVAC + + + + + + + + + + + veto + + + + + Number:Power + + The total power consumed by the device + Energy + + veto + + + + + Number:ElectricCurrent + + The current RMS current measurement + Energy + + + + + + Number:ElectricPotential + + The current RMS voltage measurement + Energy + + + + + + Switch + + Indicates a binary input sensor state + + + + + + + Switch + + Contact sensor + Door + + + + + + Switch + + Motion intrusion sensor + Motion + + + + + + Switch + + Carbon Monoxide Alarm + Sensor + + + + + + Switch + + Fire Indication Alarm + SmokeDetector + + + + + + Switch + + Motion presence sensor + Motion + + + + + + Switch + + + + + + + + + Switch + + Water Sensor Alarm + Sensor + + + + + + Switch + + Movement Sensor Alarm + Sensor + + + + + + Switch + + Vibration Sensor Alarm + Sensor + + + + + + Switch + + Indicates if a device is tampered with + Alarm + + + + + + Number + + Indicates the current illuminance in lux + + + + + + + Number:Pressure + + Indicates the current pressure + Pressure + + + + + + Number + + Indicates the current relative humidity + Humidity + + + + + + Number:Temperature + + Indicates the current temperature + Temperature + + + + + + Number + + The instantaneous demand from the metering system + Number + veto + + + + + Number + + The total delivered from the metering system + Number + veto + + + + + Number + + The total delivered from the metering system + Number + veto + + + + + Switch + + Indicates if an occupancy sensor is triggered + Motion + + + + + + Switch + + Switches the power on and off + Light + veto + + + + + Dimmer + + Sets the level of the light + Light + veto + + + + + Number:Temperature + + Indicates the local temperature provided by the thermostat + HVAC + + + + + + Number:Temperature + + Indicates the outdoor temperature provided by the thermostat + HVAC + + + + + + Number:Temperature + + Set the heating temperature when the room is occupied + HVAC + + veto + + + + + Number:Temperature + + Set the cooling temperature when the room is occupied + HVAC + + veto + + + + + Number:Temperature + + Set the heating temperature when the room is unoccupied + HVAC + + veto + + + + + Number:Temperature + + Set the cooling temperature when the room is unoccupied + HVAC + + veto + + + + + Number + + Set the system mode of the thermostat + HVAC + + + + + + + + + + + + + + veto + + + + + Number + + The running mode of the thermostat + HVAC + + + + + + + + + + + + String + + Triggers warnings on a warning device + Siren + + + + 60 + + Maximal time in seconds that the siren will sound continuously + seconds + false + + + + This configuration parameter is used to configure command options for warning/squawk types to be displayed by UIs; see options for examples + + + + + + + + false + + + + + + + Rollershutter + + Sets the window covering level - supporting open/close and up/down type commands + + Blinds + + + + + trigger + + Emits events when button is pressed + + + + + + + + + + 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 be3f24cd9..7efc42aeb 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 @@ -419,18 +419,4 @@ Blinds - - - trigger - - Emits events when button is pressed - - - - - - - - - From fa8f2c969d3252b3f5349d2bdb57b588800a3eb8 Mon Sep 17 00:00:00 2001 From: Chris Jackson Date: Wed, 10 Nov 2021 22:12:20 +1300 Subject: [PATCH 3/3] Update Signed-off-by: Chris Jackson --- .gitignore | 1 + CONTRIBUTING.md | 2 +- .../zigbee/tuya/TuyaBindingConstants.java | 6 +- .../tuya/handler/TuyaBlindsThingHandler.java | 37 ++ .../tuya/internal/TuyaHandlerFactory.java | 93 ++++ .../converter/ZigBeeConverterTuyaButton.java | 77 +-- .../ZigBeeTuyaChannelConverterProvider.java | 6 +- .../ZigBeeTuyaDiscoveryParticipant.java | 2 +- .../zigbee/TuyaBlindsMoveCommand.java | 63 +++ .../zigbee/TuyaBlindsSetPositionCommand.java | 43 ++ .../{ => zigbee}/TuyaButtonPressCommand.java | 2 +- .../tuya/internal/zigbee/ZclTuyaCommand.java | 39 ++ .../src/main/resources/OH-INF/discovery.txt | 1 + .../src/main/resources/OH-INF/thing/am25.xml | 30 ++ .../main/resources/OH-INF/thing/channels.xml | 443 +----------------- .../OH-INF/thing/{tuya => }/ts0041.xml | 10 +- .../OH-INF/thing/{tuya => }/ts0042.xml | 10 +- .../OH-INF/thing/{tuya => }/ts0043.xml | 10 +- .../OH-INF/thing/{tuya => }/ts0044.xml | 6 - .../ZigBeeConverterTuyaButtonTest.java | 9 +- .../converter/ZigBeeBaseChannelConverter.java | 15 +- .../ZigBeeThingTypeMatcher.java | 2 +- .../ZigBeeDefaultDiscoveryParticipant.java | 2 +- ...ndler.java => ZigBeeBaseThingHandler.java} | 280 +++-------- .../handler/ZigBeeGenericThingHandler.java | 256 ++++++++++ .../zigbee/handler/ZigBeeIsAliveTracker.java | 29 +- .../internal/ZigBeeDeviceConfigHandler.java | 4 +- .../zigbee/internal/ZigBeeHandlerFactory.java | 5 +- .../ZigBeeConverterAtmosphericPressure.java | 8 +- .../ZigBeeConverterBatteryAlarm.java | 8 +- .../ZigBeeConverterBatteryPercent.java | 8 +- .../ZigBeeConverterBatteryVoltage.java | 8 +- .../converter/ZigBeeConverterBinaryInput.java | 8 +- .../converter/ZigBeeConverterColorColor.java | 10 +- .../ZigBeeConverterColorTemperature.java | 8 +- .../converter/ZigBeeConverterDoorLock.java | 4 +- .../converter/ZigBeeConverterFanControl.java | 4 +- .../ZigBeeConverterGenericButton.java | 6 +- .../converter/ZigBeeConverterIas.java | 6 +- .../ZigBeeConverterIasCieSystem.java | 6 +- .../ZigBeeConverterIasCoDetector.java | 6 +- .../ZigBeeConverterIasContactPortal1.java | 6 +- .../ZigBeeConverterIasFireIndicator.java | 6 +- .../ZigBeeConverterIasLowBattery.java | 6 +- .../ZigBeeConverterIasMotionIntrusion.java | 6 +- .../ZigBeeConverterIasMotionPresence.java | 6 +- .../converter/ZigBeeConverterIasMovement.java | 6 +- .../converter/ZigBeeConverterIasTamper.java | 6 +- .../ZigBeeConverterIasVibration.java | 6 +- .../ZigBeeConverterIasWaterSensor.java | 6 +- .../converter/ZigBeeConverterIlluminance.java | 10 +- .../ZigBeeConverterMeasurementPower.java | 8 +- .../ZigBeeConverterMeasurementRmsCurrent.java | 8 +- .../ZigBeeConverterMeasurementRmsVoltage.java | 8 +- ...eConverterMeteringInstantaneousDemand.java | 4 +- ...eeConverterMeteringSummationDelivered.java | 4 +- ...BeeConverterMeteringSummationReceived.java | 4 +- .../converter/ZigBeeConverterOccupancy.java | 8 +- .../ZigBeeConverterRelativeHumidity.java | 8 +- .../converter/ZigBeeConverterSwitchLevel.java | 4 +- .../converter/ZigBeeConverterSwitchOnoff.java | 4 +- .../converter/ZigBeeConverterTemperature.java | 8 +- ...eeConverterThermostatLocalTemperature.java | 4 +- ...BeeConverterThermostatOccupiedCooling.java | 4 +- ...BeeConverterThermostatOccupiedHeating.java | 4 +- ...ConverterThermostatOutdoorTemperature.java | 4 +- .../ZigBeeConverterThermostatRunningMode.java | 4 +- .../ZigBeeConverterThermostatSystemMode.java | 4 +- ...eConverterThermostatUnoccupiedCooling.java | 4 +- ...eConverterThermostatUnoccupiedHeating.java | 4 +- .../ZigBeeConverterWindowCoveringLift.java | 10 +- .../ZigBeeConverterWarningDevice.java | 12 +- .../thing/xiaomi/lumiremoteb286acn01.xml | 6 - .../OH-INF/thing/xiaomi/lumisensor-magnet.xml | 6 - .../OH-INF/thing/xiaomi/lumisensor-motion.xml | 6 - ...switchaq2.xml => lumisensor-switchaq2.xml} | 6 - .../OH-INF/thing/xiaomi/lumisensor86sw2.xml | 6 - .../OH-INF/thing/xiaomi/lumisensorht.xml | 6 - .../OH-INF/thing/xiaomi/lumiwleak-aq1.xml | 6 - ...ZigBeeDefaultDiscoveryParticipantTest.java | 2 +- .../handler/ZigBeeThingHandlerTest.java | 12 +- .../internal/ZigBeeThingTypeMatcherTest.java | 1 + ...igBeeConverterAtmosphericPressureTest.java | 4 +- .../ZigBeeConverterBatteryAlarmTest.java | 6 +- .../ZigBeeConverterColorColorTest.java | 6 +- .../ZigBeeConverterColorTemperatureTest.java | 8 +- .../ZigBeeConverterGenericButtonTest.java | 6 +- .../ZigBeeConverterIasTamperTest.java | 6 +- ...verterMeteringInstantaneousDemandTest.java | 4 +- ...nverterMeteringSummationDeliveredTest.java | 4 +- ...onverterMeteringSummationReceivedTest.java | 4 +- .../ZigBeeConverterSwitchLevelTest.java | 4 +- .../ZigBeeConverterSwitchOnoffTest.java | 4 +- .../ZigBeeConverterTemperatureTest.java | 4 +- .../ZigBeeConverterWarningDeviceTest.java | 6 +- 95 files changed, 887 insertions(+), 995 deletions(-) create mode 100644 org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/handler/TuyaBlindsThingHandler.java create mode 100644 org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaHandlerFactory.java rename org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/{ => internal}/converter/ZigBeeConverterTuyaButton.java (74%) rename org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/{ => internal}/converter/ZigBeeTuyaChannelConverterProvider.java (87%) create mode 100644 org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/TuyaBlindsMoveCommand.java create mode 100644 org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/TuyaBlindsSetPositionCommand.java rename org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/{ => zigbee}/TuyaButtonPressCommand.java (97%) create mode 100644 org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/ZclTuyaCommand.java create mode 100644 org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/am25.xml rename org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/{tuya => }/ts0041.xml (86%) rename org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/{tuya => }/ts0042.xml (87%) rename org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/{tuya => }/ts0043.xml (88%) rename org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/{tuya => }/ts0044.xml (91%) rename org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/{internal => discovery}/ZigBeeThingTypeMatcher.java (99%) rename org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/{ZigBeeThingHandler.java => ZigBeeBaseThingHandler.java} (72%) mode change 100755 => 100644 create mode 100755 org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeGenericThingHandler.java rename org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/{xiaomi_lumisensor-switchaq2.xml => lumisensor-switchaq2.xml} (90%) diff --git a/.gitignore b/.gitignore index c5d5e8459..996b7110a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ bin/ target/ **/.settings/org.eclipse.* +*.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index de1e32f6f..a64a9ae66 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -133,7 +133,7 @@ using your real name (sorry, no pseudonyms or anonymous contributions.) There are several exceptions to the signing requirement. Currently these are: * Your patch fixes spelling or grammar errors. -* Your patch is a single line change to documentation. +* Your patch is a small change to documentation. ## Community Guidelines diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/TuyaBindingConstants.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/TuyaBindingConstants.java index 30edaa3f8..2d7f960b4 100644 --- a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/TuyaBindingConstants.java +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/TuyaBindingConstants.java @@ -13,6 +13,8 @@ package org.openhab.binding.zigbee.tuya; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.type.ChannelTypeUID; /** @@ -24,7 +26,9 @@ @NonNullByDefault public class TuyaBindingConstants { - public static final String BINDING_ID = "zigbee"; + // List of Thing Type UIDs + public final static ThingTypeUID THING_TYPE_TUYA_BLIND_AM25 = new ThingTypeUID(ZigBeeBindingConstants.BINDING_ID, + "tuya_am25"); public static final String CHANNEL_NAME_TUYA_BUTTON = "tuyabutton"; public static final String CHANNEL_LABEL_TUYA_BUTTON = "Button"; diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/handler/TuyaBlindsThingHandler.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/handler/TuyaBlindsThingHandler.java new file mode 100644 index 000000000..98d13264f --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/handler/TuyaBlindsThingHandler.java @@ -0,0 +1,37 @@ +package org.openhab.binding.zigbee.tuya.handler; + +import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeIsAliveTracker; +import org.openhab.core.thing.Thing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.zsmartsystems.zigbee.ZigBeeEndpoint; +import com.zsmartsystems.zigbee.ZigBeeNode; + +/** + * Handler for Tuya AM25 blinds + * + * @author Chris Jackson - Initial Contribution + * + */ +public class TuyaBlindsThingHandler extends ZigBeeBaseThingHandler { + private Logger logger = LoggerFactory.getLogger(TuyaBlindsThingHandler.class); + + public TuyaBlindsThingHandler(Thing zigbeeDevice, ZigBeeChannelConverterFactory channelFactory, + ZigBeeIsAliveTracker zigbeeIsAliveTracker) { + super(zigbeeDevice, channelFactory, zigbeeIsAliveTracker); + // TODO Auto-generated constructor stub + } + + @Override + protected void doNodeInitialisation(ZigBeeNode node) { + ZigBeeEndpoint endpoint = node.getEndpoint(1); + if (endpoint == null) { + logger.error("{}: Tuya blinds handler couldn't find endpoint 1", node.getIeeeAddress()); + return; + } + } + +} diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaHandlerFactory.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaHandlerFactory.java new file mode 100644 index 000000000..ed0753c60 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaHandlerFactory.java @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2010-2021 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.tuya.internal; + +import java.util.Hashtable; + +import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory; +import org.openhab.binding.zigbee.discovery.ZigBeeThingTypeMatcher; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeIsAliveTracker; +import org.openhab.binding.zigbee.tuya.TuyaBindingConstants; +import org.openhab.binding.zigbee.tuya.handler.TuyaBlindsThingHandler; +import org.openhab.core.config.core.ConfigDescriptionProvider; +import org.openhab.core.thing.Thing; +import org.openhab.core.thing.ThingTypeUID; +import org.openhab.core.thing.binding.BaseThingHandlerFactory; +import org.openhab.core.thing.binding.ThingHandler; +import org.openhab.core.thing.binding.ThingHandlerFactory; +import org.openhab.core.thing.type.DynamicStateDescriptionProvider; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; + +/** + * The {@link TuyaHandlerFactory} is responsible for creating things and thing + * handlers for Tuya devices. + * + * @author Chris Jackson - Initial contribution + */ +@Component(service = ThingHandlerFactory.class) +public class TuyaHandlerFactory extends BaseThingHandlerFactory { + + private final ZigBeeThingTypeMatcher matcher = new ZigBeeThingTypeMatcher(); + + private ZigBeeChannelConverterFactory zigbeeChannelConverterFactory; + private ZigBeeIsAliveTracker zigbeeIsAliveTracker; + + @Override + public boolean supportsThingType(ThingTypeUID thingTypeUID) { + return matcher.getSupportedThingTypeUIDs().contains(thingTypeUID); + } + + @Override + protected ThingHandler createHandler(Thing thing) { + if (!supportsThingType(thing.getThingTypeUID())) { + return null; + } + + ZigBeeBaseThingHandler handler; + + // Check for thing types with a custom thing handler + if (thing.getThingTypeUID().equals(TuyaBindingConstants.THING_TYPE_TUYA_BLIND_AM25)) { + handler = new TuyaBlindsThingHandler(thing, zigbeeChannelConverterFactory, zigbeeIsAliveTracker); + } else { + handler = new ZigBeeGenericThingHandler(thing, zigbeeChannelConverterFactory, zigbeeIsAliveTracker); + } + + bundleContext.registerService(ConfigDescriptionProvider.class.getName(), handler, + new Hashtable()); + bundleContext.registerService(DynamicStateDescriptionProvider.class.getName(), handler, + new Hashtable()); + + return handler; + } + + @Reference + protected void setZigBeeChannelConverterFactory(ZigBeeChannelConverterFactory zigbeeChannelConverterFactory) { + this.zigbeeChannelConverterFactory = zigbeeChannelConverterFactory; + } + + protected void unsetZigBeeChannelConverterFactory(ZigBeeChannelConverterFactory zigbeeChannelConverterFactory) { + this.zigbeeChannelConverterFactory = null; + } + + @Reference + protected void setZigbeeIsAliveTracker(ZigBeeIsAliveTracker zigbeeIsAliveTracker) { + this.zigbeeIsAliveTracker = zigbeeIsAliveTracker; + } + + protected void unsetZigbeeIsAliveTracker(ZigBeeIsAliveTracker zigbeeIsAliveTracker) { + this.zigbeeIsAliveTracker = null; + } +} diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButton.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/converter/ZigBeeConverterTuyaButton.java similarity index 74% rename from org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButton.java rename to org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/converter/ZigBeeConverterTuyaButton.java index 40778c4e4..ff36b4694 100644 --- a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButton.java +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/converter/ZigBeeConverterTuyaButton.java @@ -10,29 +10,28 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.zigbee.tuya.converter; +package org.openhab.binding.zigbee.tuya.internal.converter; -import static java.lang.Integer.*; +import static java.lang.Integer.toHexString; import java.util.Collections; import java.util.HashMap; import java.util.Set; import java.util.concurrent.ExecutionException; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; +import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; +import org.openhab.binding.zigbee.tuya.internal.zigbee.TuyaButtonPressCommand; import org.openhab.core.thing.Channel; import org.openhab.core.thing.CommonTriggerEvents; import org.openhab.core.thing.ThingUID; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; -import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; -import org.openhab.binding.zigbee.tuya.internal.TuyaButtonPressCommand; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.zsmartsystems.zigbee.CommandResult; import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.ZclAttribute; -import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; import com.zsmartsystems.zigbee.zcl.ZclCluster; import com.zsmartsystems.zigbee.zcl.ZclCommand; import com.zsmartsystems.zigbee.zcl.ZclCommandListener; @@ -47,19 +46,18 @@ * As the configuration is done via channel properties, this converter is usable via static thing types only. * * @author Daniel Schall - initial contribution + * @author Chris Jackson - minor updates and refactoring to separate bundle */ -public class ZigBeeConverterTuyaButton extends ZigBeeBaseChannelConverter - implements ZclAttributeListener, ZclCommandListener { +public class ZigBeeConverterTuyaButton extends ZigBeeBaseChannelConverter implements ZclCommandListener { private Logger logger = LoggerFactory.getLogger(ZigBeeConverterTuyaButton.class); private ZclCluster clientCluster = null; - private ZclCluster serverCluster = null; // Tuya devices sometimes send duplicate commands with the same tx id. // We keep track of the last received Tx id and ignore the duplicate. private Integer lastTxId = -1; - + @Override public Set getImplementedClientClusters() { return Collections.singleton(ZclOnOffCluster.CLUSTER_ID); @@ -77,13 +75,14 @@ public boolean initializeDevice() { if (clientCluster == null) { logger.error("{}: Error opening client cluster {} on endpoint {}", endpoint.getIeeeAddress(), - ZclOnOffCluster.CLUSTER_ID, endpoint.getEndpointId()); + ZclOnOffCluster.CLUSTER_ID, endpoint.getEndpointId()); return false; } + // TODO Server side is not used in operation, so is it needed here? if (serverCluster == null) { logger.error("{}: Error opening server cluster {} on endpoint {}", endpoint.getIeeeAddress(), - ZclOnOffCluster.CLUSTER_ID, endpoint.getEndpointId()); + ZclOnOffCluster.CLUSTER_ID, endpoint.getEndpointId()); return false; } @@ -115,34 +114,26 @@ public boolean initializeDevice() { } } catch (InterruptedException | ExecutionException e) { logger.error("{}: Exception setting client binding to cluster {}: {}", endpoint.getIeeeAddress(), - ZclOnOffCluster.CLUSTER_ID, e); + ZclOnOffCluster.CLUSTER_ID, e); } return true; } @Override - public synchronized boolean initializeConverter(ZigBeeThingHandler thing) { + public synchronized boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); clientCluster = endpoint.getOutputCluster(ZclOnOffCluster.CLUSTER_ID); - serverCluster = endpoint.getInputCluster(ZclOnOffCluster.CLUSTER_ID); if (clientCluster == null) { logger.error("{}: Error opening device client controls", endpoint.getIeeeAddress()); return false; } - if (serverCluster == null) { - logger.error("{}: Error opening device server controls", endpoint.getIeeeAddress()); - return false; - } - clientCluster.addCommandListener(this); - serverCluster.addAttributeListener(this); // Add Tuya-specific command - // HashMap> commandMap = new HashMap<>(); commandMap.put(TuyaButtonPressCommand.COMMAND_ID, TuyaButtonPressCommand.class); clientCluster.addClientCommands(commandMap); @@ -152,17 +143,9 @@ public synchronized boolean initializeConverter(ZigBeeThingHandler thing) { @Override public void disposeConverter() { - if(clientCluster != null) { + if (clientCluster != null) { clientCluster.removeCommandListener(this); } - if (serverCluster != null) { - serverCluster.removeAttributeListener(this); - } - } - - @Override - public void handleRefresh() { - // nothing to do, as we only listen to commands } @Override @@ -174,34 +157,24 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) { @Override public boolean commandReceived(ZclCommand command) { - logger.debug("{} received command {}", endpoint.getIeeeAddress(), command); + logger.debug("{}: Received command {}", endpoint.getIeeeAddress(), command); Integer thisTxId = command.getTransactionId(); - if(lastTxId == thisTxId) - { - logger.debug("{} ignoring duplicate command {}", endpoint.getIeeeAddress(), thisTxId); - } - else if (command instanceof TuyaButtonPressCommand) { + if (lastTxId == thisTxId) { + logger.debug("{}: Ignoring duplicate command {}", endpoint.getIeeeAddress(), thisTxId); + } else if (command instanceof TuyaButtonPressCommand) { TuyaButtonPressCommand tuyaButtonPressCommand = (TuyaButtonPressCommand) command; - thing.triggerChannel(channel.getUID(), getEventType(tuyaButtonPressCommand.getPressType())); - clientCluster.sendDefaultResponse(command, ZclStatus.SUCCESS); - } - else { - logger.warn("{} received unknown command {}", endpoint.getIeeeAddress(), command); + thing.triggerChannel(channel.getUID(), getEventType(tuyaButtonPressCommand.getPressType())); + clientCluster.sendDefaultResponse(command, ZclStatus.SUCCESS); + } else { + logger.warn("{}: Received unknown command {}", endpoint.getIeeeAddress(), command); } lastTxId = thisTxId; return true; } - @Override - public void attributeUpdated(ZclAttribute attribute, Object val) { - logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute); - } - - private String getEventType(Integer pressType) - { - switch(pressType) - { + private String getEventType(Integer pressType) { + switch (pressType) { case 0: return CommonTriggerEvents.SHORT_PRESSED; case 1: diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeTuyaChannelConverterProvider.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/converter/ZigBeeTuyaChannelConverterProvider.java similarity index 87% rename from org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeTuyaChannelConverterProvider.java rename to org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/converter/ZigBeeTuyaChannelConverterProvider.java index d43df6e61..38ca9917a 100644 --- a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeTuyaChannelConverterProvider.java +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/converter/ZigBeeTuyaChannelConverterProvider.java @@ -10,15 +10,15 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.zigbee.tuya.converter; +package org.openhab.binding.zigbee.tuya.internal.converter; import java.util.HashMap; import java.util.Map; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory; import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterProvider; +import org.openhab.binding.zigbee.tuya.TuyaBindingConstants; import org.openhab.core.thing.type.ChannelTypeUID; import org.osgi.service.component.annotations.Component; @@ -35,7 +35,7 @@ public final class ZigBeeTuyaChannelConverterProvider implements ZigBeeChannelCo public ZigBeeTuyaChannelConverterProvider() { // Add all the converters into the map... - channelMap.put(ZigBeeBindingConstants.CHANNEL_COLOR_COLOR, ZigBeeConverterTuyaButton.class); + channelMap.put(TuyaBindingConstants.CHANNEL_TUYA_BUTTON, ZigBeeConverterTuyaButton.class); } @Override diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/discovery/ZigBeeTuyaDiscoveryParticipant.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/discovery/ZigBeeTuyaDiscoveryParticipant.java index 68ea2d4d2..4a406c3de 100644 --- a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/discovery/ZigBeeTuyaDiscoveryParticipant.java +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/discovery/ZigBeeTuyaDiscoveryParticipant.java @@ -16,7 +16,7 @@ import java.util.Set; import org.openhab.binding.zigbee.discovery.ZigBeeDiscoveryParticipant; -import org.openhab.binding.zigbee.internal.ZigBeeThingTypeMatcher; +import org.openhab.binding.zigbee.discovery.ZigBeeThingTypeMatcher; import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResultBuilder; import org.openhab.core.thing.Thing; diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/TuyaBlindsMoveCommand.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/TuyaBlindsMoveCommand.java new file mode 100644 index 000000000..bb50e35d6 --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/TuyaBlindsMoveCommand.java @@ -0,0 +1,63 @@ +package org.openhab.binding.zigbee.tuya.internal.zigbee; + +import com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer; +import com.zsmartsystems.zigbee.zcl.ZclFieldSerializer; +import com.zsmartsystems.zigbee.zcl.protocol.ZclDataType; + +/** + * + * @author Chris Jackson - Initial Contribution + * + */ +public class TuyaBlindsMoveCommand extends ZclTuyaCommand { + public enum Direction { + UP, + DOWN, + STOP + } + + private static int DIRECTION_UP = 0; + private static int DIRECTION_DOWN = 2; + private static int DIRECTION_STOP = 1; + + private final Direction direction; + + public TuyaBlindsMoveCommand(Direction direction) { + this.direction = direction; + } + + @Override + public void serialize(final ZclFieldSerializer serializer) { + super.serialize(serializer); + + serializer.serialize(0x01, ZclDataType.UNSIGNED_8_BIT_INTEGER); + serializer.serialize(0x04, ZclDataType.UNSIGNED_8_BIT_INTEGER); + serializer.serialize(0x00, ZclDataType.UNSIGNED_8_BIT_INTEGER); + serializer.serialize(0x01, ZclDataType.UNSIGNED_8_BIT_INTEGER); + + switch (direction) { + case DOWN: + serializer.serialize(DIRECTION_DOWN, ZclDataType.UNSIGNED_8_BIT_INTEGER); + break; + case UP: + serializer.serialize(DIRECTION_UP, ZclDataType.UNSIGNED_8_BIT_INTEGER); + break; + case STOP: + default: + serializer.serialize(DIRECTION_STOP, ZclDataType.UNSIGNED_8_BIT_INTEGER); + break; + } + + } + + @Override + public void deserialize(final ZclFieldDeserializer deserializer) { + // Not expected to get here + } + + @Override + public String toString() { + return "TuyaBlindsMoveCommand [" + super.toString() + ", direction=" + direction + "]"; + } + +} diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/TuyaBlindsSetPositionCommand.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/TuyaBlindsSetPositionCommand.java new file mode 100644 index 000000000..d6b2a28ac --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/TuyaBlindsSetPositionCommand.java @@ -0,0 +1,43 @@ +package org.openhab.binding.zigbee.tuya.internal.zigbee; + +import com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer; +import com.zsmartsystems.zigbee.zcl.ZclFieldSerializer; +import com.zsmartsystems.zigbee.zcl.protocol.ZclDataType; + +/** + * + * @author Chris Jackson - Initial Contribution + * + */ +public class TuyaBlindsSetPositionCommand extends ZclTuyaCommand { + private final int position; + + public TuyaBlindsSetPositionCommand(int position) { + this.position = position; + } + + @Override + public void serialize(final ZclFieldSerializer serializer) { + super.serialize(serializer); + + serializer.serialize(0x02, ZclDataType.UNSIGNED_8_BIT_INTEGER); + serializer.serialize(0x02, ZclDataType.UNSIGNED_8_BIT_INTEGER); + serializer.serialize(0x00, ZclDataType.UNSIGNED_8_BIT_INTEGER); + serializer.serialize(0x04, ZclDataType.UNSIGNED_8_BIT_INTEGER); + serializer.serialize(0x00, ZclDataType.UNSIGNED_8_BIT_INTEGER); + serializer.serialize(0x00, ZclDataType.UNSIGNED_8_BIT_INTEGER); + serializer.serialize(0x00, ZclDataType.UNSIGNED_8_BIT_INTEGER); + serializer.serialize(position, ZclDataType.UNSIGNED_8_BIT_INTEGER); + } + + @Override + public void deserialize(final ZclFieldDeserializer deserializer) { + // Not expected to get here + } + + @Override + public String toString() { + return "TuyaBlindsSetPositionCommand [" + super.toString() + ", position=" + position + "]"; + } + +} diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaButtonPressCommand.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/TuyaButtonPressCommand.java similarity index 97% rename from org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaButtonPressCommand.java rename to org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/TuyaButtonPressCommand.java index 0d80c2da3..138edaa6f 100644 --- a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaButtonPressCommand.java +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/TuyaButtonPressCommand.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.zigbee.tuya.internal; +package org.openhab.binding.zigbee.tuya.internal.zigbee; import com.zsmartsystems.zigbee.zcl.ZclCommand; import com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer; diff --git a/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/ZclTuyaCommand.java b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/ZclTuyaCommand.java new file mode 100644 index 000000000..8f667f75e --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/zigbee/ZclTuyaCommand.java @@ -0,0 +1,39 @@ +package org.openhab.binding.zigbee.tuya.internal.zigbee; + +import com.zsmartsystems.zigbee.zcl.ZclCommand; +import com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer; +import com.zsmartsystems.zigbee.zcl.ZclFieldSerializer; +import com.zsmartsystems.zigbee.zcl.protocol.ZclDataType; + +/** + * Abstract base command class for all commands in the Tuya cluster (Cluster ID 0xEF00). + * All commands sent through the {@link ZclTuyaCluster} must extend this class. + * + * @author Chris Jackson - Initial Contribution + */ +public abstract class ZclTuyaCommand extends ZclCommand { + private int sequence; + protected int[] data; + + protected void setSequenceCounter(int sequence) { + this.sequence = sequence; + } + + @Override + public void serialize(final ZclFieldSerializer serializer) { + serializer.serialize(0x00, ZclDataType.UNSIGNED_8_BIT_INTEGER); + serializer.serialize(sequence, ZclDataType.UNSIGNED_8_BIT_INTEGER); + + } + + @Override + public void deserialize(final ZclFieldDeserializer deserializer) { + deserializer.deserialize(ZclDataType.UNSIGNED_8_BIT_INTEGER); + sequence = (Integer) deserializer.deserialize(ZclDataType.UNSIGNED_8_BIT_INTEGER); + } + + @Override + public String toString() { + return String.format("sequence=%02X", sequence); + } +} diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/discovery.txt b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/discovery.txt index d4fef60fa..780391aaa 100644 --- a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/discovery.txt +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/discovery.txt @@ -1,3 +1,4 @@ +tuya_am25,vendor=_TZE200_zuz7f94z,modelId=TS0601 tuya_ts0041,vendor=_TZ3000_tk3s5tyg,modelId=TS0041 tuya_ts0042,vendor=_TZ3000_adkvzooy,modelId=TS0042 tuya_ts0043,vendor=_TZ3000_qzjcsmar,modelId=TS0043 diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/am25.xml b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/am25.xml new file mode 100644 index 000000000..647414fde --- /dev/null +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/am25.xml @@ -0,0 +1,30 @@ + + + + + + Smart Blinds Motor + Blinds + + + + + + 1 + + + + + + zigbee_macaddress + + + + + + + + \ No newline at end of file diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/channels.xml b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/channels.xml index be3f24cd9..72113a8ff 100644 --- a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/channels.xml +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/channels.xml @@ -1,436 +1,21 @@ - - - - Number:ElectricPotential - - The current battery voltage - Energy - - - - - - String - - The battery alarm state - Energy - - - - - - - - - - - - - - Color - - The color channel allows to control the color of a light. - It is also possible to dim values and switch the light on and off. - - ColorLight - veto - - - - - Switch - - Locks and unlocks the door and maintains the lock state - Door - veto - - - - - Number - - Set the fan mode - HVAC - - - - - - - - - - - veto - - - - - Number:Power - - The total power consumed by the device - Energy - - veto - - - - - Number:ElectricCurrent - - The current RMS current measurement - Energy - - - - - - Number:ElectricPotential - - The current RMS voltage measurement - Energy - - - - - - Switch - - Indicates a binary input sensor state - - - - - - - Switch - - Contact sensor - Door - - - - - - Switch - - Motion intrusion sensor - Motion - - - - - - Switch - - Carbon Monoxide Alarm - Sensor - - - - - - Switch - - Fire Indication Alarm - SmokeDetector - - - - - - Switch - - Motion presence sensor - Motion - - - - - - Switch - - - - - - - - - Switch - - Water Sensor Alarm - Sensor - - - - - - Switch - - Movement Sensor Alarm - Sensor - - - - - - Switch - - Vibration Sensor Alarm - Sensor - - - - - - Switch - - Indicates if a device is tampered with - Alarm - - - - - - Number - - Indicates the current illuminance in lux - - - - - - - Number:Pressure - - Indicates the current pressure - Pressure - - - - - - Number - - Indicates the current relative humidity - Humidity - - - - - - Number:Temperature - - Indicates the current temperature - Temperature - - - - - - Number - - The instantaneous demand from the metering system - Number - veto - - - - - Number - - The total delivered from the metering system - Number - veto - - - - - Number - - The total delivered from the metering system - Number - veto - - - - - Switch - - Indicates if an occupancy sensor is triggered - Motion - - - - - - Switch - - Switches the power on and off - Light - veto - - - - - Dimmer - - Sets the level of the light - Light - veto - - - - - Number:Temperature - - Indicates the local temperature provided by the thermostat - HVAC - - - - - - Number:Temperature - - Indicates the outdoor temperature provided by the thermostat - HVAC - - - - - - Number:Temperature - - Set the heating temperature when the room is occupied - HVAC - - veto - - - - - Number:Temperature - - Set the cooling temperature when the room is occupied - HVAC - - veto - - - - - Number:Temperature - - Set the heating temperature when the room is unoccupied - HVAC - - veto - - - - - Number:Temperature - - Set the cooling temperature when the room is unoccupied - HVAC - - veto - - - - - Number - - Set the system mode of the thermostat - HVAC - - - - - - - - - - - - - - veto - - - - - Number - - The running mode of the thermostat - HVAC - - - - - - - - - - - - String - - Triggers warnings on a warning device - Siren - - - - 60 - - Maximal time in seconds that the siren will sound continuously - seconds - false - - - - This configuration parameter is used to configure command options for warning/squawk types to be displayed by UIs; see options for examples - - - - - - - - false - - + + + trigger + + Emits events when button is pressed + + + + + + + - - - Rollershutter - - Sets the window covering level - supporting open/close and up/down type commands - - Blinds - - - - - trigger - - Emits events when button is pressed - - - - - - - - - diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0041.xml b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0041.xml similarity index 86% rename from org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0041.xml rename to org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0041.xml index 03ba99c98..97db9146f 100644 --- a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0041.xml +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0041.xml @@ -4,7 +4,7 @@ xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> - + Generic Tuya 1-Button Wall Switch WallSwitch @@ -16,7 +16,7 @@ 1 - + 1 @@ -38,12 +38,6 @@ - - Tuya - TS0041 - END_DEVICE - - zigbee_macaddress diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0042.xml b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0042.xml similarity index 87% rename from org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0042.xml rename to org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0042.xml index 4d4be2664..0a0925ea2 100644 --- a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0042.xml +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0042.xml @@ -4,7 +4,7 @@ xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> - + Generic Tuya 2-Button Wall Switch WallSwitch @@ -16,7 +16,7 @@ 1 - + 1 @@ -45,12 +45,6 @@ - - Tuya - TS0042 - END_DEVICE - - zigbee_macaddress diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0043.xml b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0043.xml similarity index 88% rename from org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0043.xml rename to org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0043.xml index 51166fe8e..982ed77e8 100644 --- a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0043.xml +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0043.xml @@ -4,7 +4,7 @@ xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> - + Generic Tuya 3-Button Wall Switch WallSwitch @@ -16,7 +16,7 @@ 1 - + 1 @@ -52,12 +52,6 @@ - - Tuya - TS0043 - END_DEVICE - - zigbee_macaddress diff --git a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0044.xml b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0044.xml similarity index 91% rename from org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0044.xml rename to org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0044.xml index fd43b18d1..6e7e738a0 100644 --- a/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/tuya/ts0044.xml +++ b/org.openhab.binding.zigbee.tuya/src/main/resources/OH-INF/thing/ts0044.xml @@ -58,12 +58,6 @@ - - - Tuya - TS0044 - END_DEVICE - zigbee_macaddress diff --git a/org.openhab.binding.zigbee.tuya/src/test/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButtonTest.java b/org.openhab.binding.zigbee.tuya/src/test/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButtonTest.java index 99562a45c..e92bbc1a2 100644 --- a/org.openhab.binding.zigbee.tuya/src/test/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButtonTest.java +++ b/org.openhab.binding.zigbee.tuya/src/test/java/org/openhab/binding/zigbee/tuya/converter/ZigBeeConverterTuyaButtonTest.java @@ -24,8 +24,9 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; -import org.openhab.binding.zigbee.tuya.internal.TuyaButtonPressCommand; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; +import org.openhab.binding.zigbee.tuya.internal.converter.ZigBeeConverterTuyaButton; +import org.openhab.binding.zigbee.tuya.internal.zigbee.TuyaButtonPressCommand; import org.openhab.core.thing.Channel; import org.openhab.core.thing.CommonTriggerEvents; @@ -47,7 +48,7 @@ public class ZigBeeConverterTuyaButtonTest { private ZigBeeConverterTuyaButton converter; - private ZigBeeThingHandler thingHandler; + private ZigBeeGenericThingHandler thingHandler; private Channel channel; private ZigBeeCoordinatorHandler coordinatorHandler; private ZigBeeEndpoint endpoint; @@ -60,7 +61,7 @@ public void setup() { int endpointId = 1; endpoint = mock(ZigBeeEndpoint.class); - thingHandler = mock(ZigBeeThingHandler.class); + thingHandler = mock(ZigBeeGenericThingHandler.class); channel = mock(Channel.class); channelProperties = new HashMap<>(); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/converter/ZigBeeBaseChannelConverter.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/converter/ZigBeeBaseChannelConverter.java index 39bd13616..acdc37e66 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/converter/ZigBeeBaseChannelConverter.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/converter/ZigBeeBaseChannelConverter.java @@ -23,8 +23,8 @@ import org.eclipse.jdt.annotation.NonNull; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.openhab.core.config.core.ConfigDescriptionParameter; import org.openhab.core.config.core.Configuration; import org.openhab.core.library.types.PercentType; @@ -59,7 +59,7 @@ * required features are available. If so, it should return the channel. This method allows dynamic channel detection * for unknown devices and may not be called if a device is defined through another mechanism. *

  • The thing handler will call the - * {@link #initialize(ZigBeeThingHandler, Channel, ZigBeeCoordinatorHandler, IeeeAddress, int)} to initialise the + * {@link #initialize(ZigBeeBaseThingHandler, Channel, ZigBeeCoordinatorHandler, IeeeAddress, int)} to initialise the * channel * converter. This simply links the converter to the node endpoint. *
  • The thing handler will call {@link #initializeDevice()} to initialise the device. This method may not be called @@ -122,9 +122,9 @@ public abstract class ZigBeeBaseChannelConverter { protected final int POLLING_PERIOD_HIGH = 60; /** - * The {@link ZigBeeThingHandler} to which this channel belongs. + * The {@link ZigBeeBaseThingHandler} to which this channel belongs. */ - protected ZigBeeThingHandler thing = null; + protected ZigBeeBaseThingHandler thing = null; /** * The {@link ZigBeeCoordinatorHandler} that controls the network @@ -228,17 +228,18 @@ public boolean initializeDevice() { public abstract Set getImplementedServerClusters(); /** - * Initialise the converter. This is called by the {@link ZigBeeThingHandler} when the channel is created. The + * Initialise the converter. This is called by the {@link ZigBeeBaseThingHandler} when the channel is created. + * The * converter should initialise any internal states, open any clusters, add reporting and binding that it needs to * operate. *

    * A list of configuration parameters for the thing should be built and added to {@link #configOptions} based on the * features the device supports. * - * @param thing the {@link ZigBeeThingHandler} the channel is part of + * @param thing the {@link ZigBeeBaseThingHandler} the channel is part of * @return true if the converter was initialised successfully */ - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { this.thing = thing; return false; } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeThingTypeMatcher.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/discovery/ZigBeeThingTypeMatcher.java similarity index 99% rename from org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeThingTypeMatcher.java rename to org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/discovery/ZigBeeThingTypeMatcher.java index ecfbf2101..bb57bb7e9 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeThingTypeMatcher.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/discovery/ZigBeeThingTypeMatcher.java @@ -10,7 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.zigbee.internal; +package org.openhab.binding.zigbee.discovery; import java.io.BufferedReader; import java.io.IOException; diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/discovery/internal/ZigBeeDefaultDiscoveryParticipant.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/discovery/internal/ZigBeeDefaultDiscoveryParticipant.java index 2b4fff52e..222d29b78 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/discovery/internal/ZigBeeDefaultDiscoveryParticipant.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/discovery/internal/ZigBeeDefaultDiscoveryParticipant.java @@ -21,7 +21,7 @@ import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingUID; import org.openhab.binding.zigbee.discovery.ZigBeeDiscoveryParticipant; -import org.openhab.binding.zigbee.internal.ZigBeeThingTypeMatcher; +import org.openhab.binding.zigbee.discovery.ZigBeeThingTypeMatcher; import org.osgi.service.component.annotations.Component; import com.zsmartsystems.zigbee.ZigBeeNode; 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/ZigBeeBaseThingHandler.java old mode 100755 new mode 100644 similarity index 72% rename from org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java rename to org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeBaseThingHandler.java index 3fe39fef1..56995e64d --- 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/ZigBeeBaseThingHandler.java @@ -13,9 +13,7 @@ package org.openhab.binding.zigbee.handler; import java.net.URI; -import java.net.URISyntaxException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -33,22 +31,17 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory; -import org.openhab.binding.zigbee.discovery.ZigBeeNodePropertyDiscoverer; -import org.openhab.binding.zigbee.internal.ZigBeeConfigDescriptionParameters; import org.openhab.binding.zigbee.internal.ZigBeeDeviceConfigHandler; -import org.openhab.binding.zigbee.internal.converter.config.ZclClusterConfigFactory; import org.openhab.binding.zigbee.internal.converter.config.ZclClusterConfigHandler; import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; import org.openhab.core.common.ThreadPoolManager; import org.openhab.core.config.core.ConfigDescription; import org.openhab.core.config.core.ConfigDescriptionBuilder; -import org.openhab.core.config.core.ConfigDescriptionParameter; import org.openhab.core.config.core.ConfigDescriptionProvider; import org.openhab.core.config.core.Configuration; import org.openhab.core.thing.Channel; @@ -58,7 +51,6 @@ import org.openhab.core.thing.ThingStatusDetail; import org.openhab.core.thing.ThingStatusInfo; import org.openhab.core.thing.binding.BaseThingHandler; -import org.openhab.core.thing.binding.builder.ThingBuilder; import org.openhab.core.thing.binding.firmware.Firmware; import org.openhab.core.thing.binding.firmware.FirmwareUpdateHandler; import org.openhab.core.thing.binding.firmware.ProgressCallback; @@ -77,7 +69,6 @@ import com.zsmartsystems.zigbee.ZigBeeNetworkNodeListener; import com.zsmartsystems.zigbee.ZigBeeNode; import com.zsmartsystems.zigbee.ZigBeeNodeStatus; -import com.zsmartsystems.zigbee.ZigBeeProfileType; import com.zsmartsystems.zigbee.ZigBeeStatus; import com.zsmartsystems.zigbee.app.otaserver.ZclOtaUpgradeServer; import com.zsmartsystems.zigbee.app.otaserver.ZigBeeOtaFile; @@ -93,41 +84,41 @@ * @author Chris Jackson - Initial Contribution * @author Thomas Höfer - Injected ZigBeeChannelConverterFactory via constructor */ -public class ZigBeeThingHandler extends BaseThingHandler implements ZigBeeNetworkNodeListener, ZigBeeAnnounceListener, - FirmwareUpdateHandler, ConfigDescriptionProvider, DynamicStateDescriptionProvider { +public abstract class ZigBeeBaseThingHandler extends BaseThingHandler implements ZigBeeNetworkNodeListener, + ZigBeeAnnounceListener, FirmwareUpdateHandler, ConfigDescriptionProvider, DynamicStateDescriptionProvider { /** * Our logger */ - private final Logger logger = LoggerFactory.getLogger(ZigBeeThingHandler.class); + private final Logger logger = LoggerFactory.getLogger(ZigBeeBaseThingHandler.class); /** * The binding's {@link DynamicStateDescriptionProvider} */ - private final Map stateDescriptions = new ConcurrentHashMap<>(); + protected final Map stateDescriptions = new ConcurrentHashMap<>(); /** * The map of all the channels defined for this thing */ - private final Map channels = new HashMap<>(); + protected final Map channels = new HashMap<>(); /** * A list of all the configuration handlers at node level. */ - private final List configHandlers = new ArrayList<>(); + protected final List configHandlers = new ArrayList<>(); /** * The configuration description if dynamically generated */ - private ConfigDescription configDescription; + protected ConfigDescription configDescription; /** * The {@link IeeeAddress} for this device */ - private IeeeAddress nodeIeeeAddress = null; + protected IeeeAddress nodeIeeeAddress = null; - private ZigBeeCoordinatorHandler coordinatorHandler; + protected ZigBeeCoordinatorHandler coordinatorHandler; - private boolean nodeInitialised = false; + protected boolean nodeInitialised = false; private final Object pollingSync = new Object(); private ScheduledFuture pollingJob = null; @@ -152,7 +143,7 @@ public class ZigBeeThingHandler extends BaseThingHandler implements ZigBeeNetwor /** * The factory to create the converters for the different channels. */ - private final ZigBeeChannelConverterFactory channelFactory; + protected final ZigBeeChannelConverterFactory channelFactory; /** * The service with timers to see if the device is still alive (ONLINE) @@ -167,7 +158,7 @@ public class ZigBeeThingHandler extends BaseThingHandler implements ZigBeeNetwor * @param zigbeeIsAliveTracker the tracker which sets the {@link Thing} to OFFLINE after a period without * communication */ - public ZigBeeThingHandler(Thing zigbeeDevice, ZigBeeChannelConverterFactory channelFactory, + public ZigBeeBaseThingHandler(Thing zigbeeDevice, ZigBeeChannelConverterFactory channelFactory, ZigBeeIsAliveTracker zigbeeIsAliveTracker) { super(zigbeeDevice); this.channelFactory = channelFactory; @@ -186,7 +177,7 @@ public void initialize() { } nodeIeeeAddress = new IeeeAddress(configAddress); - // we do not know the current state of the device until our scheduled job has initialized the device + // We do not know the current state of the device until our scheduled job has initialized the device updateStatus(ThingStatus.UNKNOWN); if (getBridge() != null) { @@ -224,212 +215,69 @@ private void initialiseZigBeeNode() { scheduler.schedule(new Callable() { @Override public Void call() throws Exception { - doNodeInitialisation(); + ZigBeeNode node = coordinatorHandler.getNode(nodeIeeeAddress); + + doNodeInitialisation(node); + finalizeNodeInitialisation(node); return null; } }, 10, TimeUnit.MILLISECONDS); } - private synchronized void doNodeInitialisation() { - if (nodeInitialised) { - return; - } - - ZigBeeNode node = coordinatorHandler.getNode(nodeIeeeAddress); - if (node == null) { - logger.debug("{}: Node not found - deferring handler initialisation", nodeIeeeAddress); - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.GONE, ZigBeeBindingConstants.OFFLINE_NODE_NOT_FOUND); - return; - } - - // Check if discovery is complete and we know all the services the node supports - if (!node.isDiscovered()) { - logger.debug("{}: Node has not finished discovery", nodeIeeeAddress); - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, - ZigBeeBindingConstants.OFFLINE_DISCOVERY_INCOMPLETE); - return; - } - - logger.debug("{}: Start initialising ZigBee Thing handler", nodeIeeeAddress); - - // Update the general properties - ZigBeeNodePropertyDiscoverer propertyDiscoverer = new ZigBeeNodePropertyDiscoverer(); - propertyDiscoverer.setProperties(getThing().getProperties()); - Map newProperties = propertyDiscoverer.getProperties(node); - updateProperties(newProperties); - - // Clear the channels in case we are reinitialising - channels.clear(); - - // Get the configuration handlers applicable for the thing - ZclClusterConfigFactory configFactory = new ZclClusterConfigFactory(); - for (ZigBeeEndpoint endpoint : coordinatorHandler.getNodeEndpoints(nodeIeeeAddress)) { - List handlers = configFactory.getConfigHandlers(endpoint); - configHandlers.addAll(handlers); - } - - List nodeChannels; - - List parameters = new ArrayList<>( - ZigBeeConfigDescriptionParameters.getParameters()); - - if (getThing().getThingTypeUID().equals(ZigBeeBindingConstants.THING_TYPE_GENERIC_DEVICE)) { - // Dynamically create the channels from the device - // Process all the endpoints for this device and add all channels as derived from the supported clusters - nodeChannels = new ArrayList<>(); - for (ZigBeeEndpoint endpoint : coordinatorHandler.getNodeEndpoints(nodeIeeeAddress)) { - logger.debug("{}: Checking endpoint {} channels", nodeIeeeAddress, endpoint.getEndpointId()); - nodeChannels.addAll(channelFactory.getChannels(getThing().getUID(), endpoint)); - } - logger.debug("{}: Dynamically created {} channels", nodeIeeeAddress, nodeChannels.size()); - - for (ZclClusterConfigHandler handler : configHandlers) { - parameters.addAll(handler.getConfiguration()); - } - } else { - // We already have the correct thing type so just use the channels - nodeChannels = getThing().getChannels(); - logger.debug("{}: Using static definition with existing {} channels", nodeIeeeAddress, nodeChannels.size()); - } - - try { - configDescription = ConfigDescriptionBuilder.create(new URI("thing:" + getThing().getUID())) - .withParameters(parameters).build(); - } catch (IllegalArgumentException | URISyntaxException e) { - logger.debug("Error creating URI for thing description:", e); - } - - // Add statically defined endpoints and clusters - for (Channel channel : nodeChannels) { - // Process the channel properties - Map properties = channel.getProperties(); - int endpointId = Integer.parseInt(properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_ENDPOINT)); - ZigBeeEndpoint endpoint = node.getEndpoint(endpointId); - if (endpoint == null) { - int profileId; - if (properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_PROFILEID) == null) { - profileId = ZigBeeProfileType.ZIGBEE_HOME_AUTOMATION.getKey(); - } else { - profileId = Integer.parseInt(properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_PROFILEID)); - } + /** + * Called to allow the handler to perform any initialisation. + * This is called within a thread so there is no time requirement to return quickly. + * + * @param node the {@link ZigBeeNode} of the device linked to the thing + */ + abstract protected void doNodeInitialisation(ZigBeeNode node); - logger.debug("{}: Creating statically defined device endpoint {} with profile {}", nodeIeeeAddress, - endpointId, ZigBeeProfileType.getByValue(profileId)); - endpoint = new ZigBeeEndpoint(node, endpointId); - endpoint.setProfileId(profileId); - node.addEndpoint(endpoint); - } + private void finalizeNodeInitialisation(ZigBeeNode node) { + pollingPeriod = POLLING_PERIOD_MAX; - List staticClusters; - boolean modified = false; - staticClusters = processClusterList(endpoint.getInputClusterIds(), - properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_INPUTCLUSTERS)); - if (!staticClusters.isEmpty()) { - logger.debug("{}: Forcing endpoint {} input clusters {}", nodeIeeeAddress, endpointId, staticClusters); - endpoint.setInputClusterIds(staticClusters); - modified = true; + // Create the channel map to simplify processing incoming events + for (Channel channel : getThing().getChannels()) { + ZigBeeBaseChannelConverter handler = createZigBeeChannelConverter(channel); + if (handler == null) { + logger.debug("{}: No handler found for {}", nodeIeeeAddress, channel.getUID()); + continue; } - staticClusters = processClusterList(endpoint.getOutputClusterIds(), - properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_OUTPUTCLUSTERS)); - if (!staticClusters.isEmpty()) { - logger.debug("{}: Forcing endpoint {} output clusters {}", nodeIeeeAddress, endpointId, staticClusters); - endpoint.setOutputClusterIds(staticClusters); - modified = true; + if (handler.initializeConverter(this) == false) { + logger.info("{}: Channel {} failed to initialise converter", nodeIeeeAddress, channel.getUID()); + continue; } - if (modified) { - logger.debug("{}: Updating endpoint {}", nodeIeeeAddress, endpointId); - node.updateEndpoint(endpoint); + if (channel.getConfiguration().get(ZclReportingConfig.CONFIG_POLLING) == null) { + channel.getConfiguration().put(ZclReportingConfig.CONFIG_POLLING, handler.getPollingPeriod()); } - } - try { - pollingPeriod = POLLING_PERIOD_MAX; + handler.handleRefresh(); - // Check if the channels we've discovered are the same - List oldChannelUidList = new ArrayList(); - for (Channel channel : getThing().getChannels()) { - oldChannelUidList.add(channel.getUID()); - } - List newChannelUidList = new ArrayList(); - for (Channel channel : nodeChannels) { - newChannelUidList.add(channel.getUID()); - - // Add the configuration from the existing channel into the new channel - Channel currentChannel = getThing().getChannel(channel.getUID().toString()); - if (currentChannel != null) { - channel.getConfiguration().setProperties(currentChannel.getConfiguration().getProperties()); - } - } + handler.updateConfiguration(new Configuration(), channel.getConfiguration().getProperties()); - if (!newChannelUidList.equals(oldChannelUidList)) { - logger.debug("{}: Updating thing definition as channels have changed from {} to {}", nodeIeeeAddress, - oldChannelUidList, newChannelUidList); - ThingBuilder thingBuilder = editThing(); - thingBuilder.withChannels(nodeChannels).withConfiguration(getConfig()); - updateThing(thingBuilder.build()); - } + channels.put(channel.getUID(), handler); - boolean doInitializeDevice = !Boolean - .parseBoolean(thing.getProperties().get(ZigBeeBindingConstants.THING_PROPERTY_DEVICE_INITIALIZED)); - if (doInitializeDevice) { - initializeDevice(); - } else { - logger.debug("{}: Device initialization will be skipped as the device is already initialized", - nodeIeeeAddress); + if (handler.getPollingPeriod() < pollingPeriod) { + pollingPeriod = handler.getPollingPeriod(); } - // Create the channel map to simplify processing incoming events - for (Channel channel : getThing().getChannels()) { - ZigBeeBaseChannelConverter handler = createZigBeeChannelConverter(channel); - if (handler == null) { - logger.debug("{}: No handler found for {}", nodeIeeeAddress, channel.getUID()); - continue; - } - - if (handler.initializeConverter(this) == false) { - logger.info("{}: Channel {} failed to initialise converter", nodeIeeeAddress, channel.getUID()); - continue; - } - - if (channel.getConfiguration().get(ZclReportingConfig.CONFIG_POLLING) == null) { - channel.getConfiguration().put(ZclReportingConfig.CONFIG_POLLING, handler.getPollingPeriod()); - } - - handler.handleRefresh(); - - // TODO: Update the channel configuration from the device if method available - handler.updateConfiguration(new Configuration(), channel.getConfiguration().getProperties()); - - channels.put(channel.getUID(), handler); - - if (handler.getPollingPeriod() < pollingPeriod) { - pollingPeriod = handler.getPollingPeriod(); - } - - // Provide the state descriptions if the channel provides them - StateDescription stateDescription = handler.getStateDescription(); - if (stateDescription != null) { - stateDescriptions.put(channel.getUID(), stateDescription); - } + // Provide the state descriptions if the channel provides them + StateDescription stateDescription = handler.getStateDescription(); + if (stateDescription != null) { + stateDescriptions.put(channel.getUID(), stateDescription); } - } catch (Exception e) { - logger.error("{}: Exception creating channels ", nodeIeeeAddress, e); - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR); - return; } - logger.debug("{}: Channel initialisation complete", nodeIeeeAddress); if (channels.isEmpty()) { - logger.warn("{}: No supported clusters found", nodeIeeeAddress); + logger.warn("{}: No supported channels found", nodeIeeeAddress); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR, - "No supported clusters found"); + "No supported channels found"); return; } // If this is an RFD then we reduce polling to the max to avoid wasting battery - if (node.isReducedFuntionDevice()) { + if (node.isReducedFunctionDevice()) { pollingPeriod = POLLING_PERIOD_DEFAULT; logger.debug("{}: Thing is RFD, using long poll period of {}sec", nodeIeeeAddress, pollingPeriod); } @@ -461,7 +309,7 @@ private synchronized void doNodeInitialisation() { coordinatorHandler.serializeNetwork(node.getIeeeAddress()); } - private int getExpectedUpdatePeriod(Map channels) { + protected int getExpectedUpdatePeriod(Map channels) { Set intervals = new HashSet<>(); for (ZigBeeBaseChannelConverter channelConverter : channels.values()) { intervals.add(channelConverter.getPollingPeriod()); @@ -497,7 +345,7 @@ public void alive() { updateStatus(ThingStatus.ONLINE); } - private synchronized void initializeDevice() { + protected synchronized void initializeDevice() { logger.debug("{}: Initializing device", nodeIeeeAddress); getThing().setProperty(ZigBeeBindingConstants.THING_PROPERTY_DEVICE_INITIALIZED, Boolean.FALSE.toString()); @@ -521,33 +369,13 @@ private synchronized void initializeDevice() { channelInitializationSuccessful ? Boolean.TRUE.toString() : Boolean.FALSE.toString()); } - private ZigBeeBaseChannelConverter createZigBeeChannelConverter(Channel channel) { + protected ZigBeeBaseChannelConverter createZigBeeChannelConverter(Channel channel) { ZigBeeNode node = coordinatorHandler.getNode(nodeIeeeAddress); Map properties = channel.getProperties(); return channelFactory.createConverter(channel, coordinatorHandler, node.getIeeeAddress(), Integer.parseInt(properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_ENDPOINT))); } - /** - * Process a static cluster list and add it to the existing list - * - * @param initialClusters a collection of existing clusters - * @param newClusters a string containing a comma separated list of clusters - * @return a list of clusters if the list is updated, or an empty list if it has not changed - */ - private List processClusterList(Collection initialClusters, String newClusters) { - if (newClusters == null || newClusters.length() == 0) { - return Collections.emptyList(); - } - - Set clusters = new HashSet(); - clusters.addAll(initialClusters); - return clusters.addAll( - Arrays.asList(newClusters.split(",")).stream().map(s -> Integer.valueOf(s)).collect(Collectors.toSet())) - ? new ArrayList(clusters) - : Collections.emptyList(); - } - @Override public void dispose() { logger.debug("{}: Handler dispose.", nodeIeeeAddress); @@ -572,7 +400,7 @@ public void dispose() { nodeInitialised = false; } - private void stopPolling() { + protected void stopPolling() { synchronized (pollingSync) { if (pollingJob != null) { pollingJob.cancel(true); @@ -585,7 +413,7 @@ private void stopPolling() { /** * Start polling channel updates */ - private void startPolling() { + protected void startPolling() { Runnable pollingRunnable = new Runnable() { @Override public void run() { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeGenericThingHandler.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeGenericThingHandler.java new file mode 100755 index 000000000..cd57fd4cc --- /dev/null +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeGenericThingHandler.java @@ -0,0 +1,256 @@ +/** + * Copyright (c) 2010-2021 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.handler; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory; +import org.openhab.binding.zigbee.discovery.ZigBeeNodePropertyDiscoverer; +import org.openhab.binding.zigbee.internal.ZigBeeConfigDescriptionParameters; +import org.openhab.binding.zigbee.internal.converter.config.ZclClusterConfigFactory; +import org.openhab.binding.zigbee.internal.converter.config.ZclClusterConfigHandler; +import org.openhab.core.config.core.ConfigDescriptionBuilder; +import org.openhab.core.config.core.ConfigDescriptionParameter; +import org.openhab.core.config.core.ConfigDescriptionProvider; +import org.openhab.core.thing.Channel; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.Thing; +import org.openhab.core.thing.ThingStatus; +import org.openhab.core.thing.ThingStatusDetail; +import org.openhab.core.thing.binding.builder.ThingBuilder; +import org.openhab.core.thing.binding.firmware.FirmwareUpdateHandler; +import org.openhab.core.thing.type.DynamicStateDescriptionProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.zsmartsystems.zigbee.ZigBeeAnnounceListener; +import com.zsmartsystems.zigbee.ZigBeeEndpoint; +import com.zsmartsystems.zigbee.ZigBeeNetworkNodeListener; +import com.zsmartsystems.zigbee.ZigBeeNode; +import com.zsmartsystems.zigbee.ZigBeeProfileType; + +/** + * The standard ZigBee thing handler. + * + * @author Chris Jackson - Initial Contribution + */ +public class ZigBeeGenericThingHandler extends ZigBeeBaseThingHandler implements ZigBeeNetworkNodeListener, + ZigBeeAnnounceListener, FirmwareUpdateHandler, ConfigDescriptionProvider, DynamicStateDescriptionProvider { + /** + * Our logger + */ + private final Logger logger = LoggerFactory.getLogger(ZigBeeGenericThingHandler.class); + + private boolean nodeInitialised = false; + + /** + * Creates a ZigBee thing. + * + * @param zigbeeDevice the {@link Thing} + * @param channelFactory the {@link ZigBeeChannelConverterFactory} to be used to create the channels + * @param zigbeeIsAliveTracker the tracker which sets the {@link Thing} to OFFLINE after a period without + * communication + */ + public ZigBeeGenericThingHandler(Thing zigbeeDevice, ZigBeeChannelConverterFactory channelFactory, + ZigBeeIsAliveTracker zigbeeIsAliveTracker) { + super(zigbeeDevice, channelFactory, zigbeeIsAliveTracker); + } + + @Override + protected synchronized void doNodeInitialisation(ZigBeeNode node) { + if (nodeInitialised) { + return; + } + + if (node == null) { + logger.debug("{}: Node not found - deferring handler initialisation", nodeIeeeAddress); + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.GONE, ZigBeeBindingConstants.OFFLINE_NODE_NOT_FOUND); + return; + } + + // Check if discovery is complete and we know all the services the node supports + if (!node.isDiscovered()) { + logger.debug("{}: Node has not finished discovery", nodeIeeeAddress); + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, + ZigBeeBindingConstants.OFFLINE_DISCOVERY_INCOMPLETE); + return; + } + + logger.debug("{}: Start initialising ZigBee Thing handler", nodeIeeeAddress); + + // Update the general properties + ZigBeeNodePropertyDiscoverer propertyDiscoverer = new ZigBeeNodePropertyDiscoverer(); + propertyDiscoverer.setProperties(getThing().getProperties()); + Map newProperties = propertyDiscoverer.getProperties(node); + updateProperties(newProperties); + + // Clear the channels in case we are reinitialising + channels.clear(); + + // Get the configuration handlers applicable for the thing + ZclClusterConfigFactory configFactory = new ZclClusterConfigFactory(); + for (ZigBeeEndpoint endpoint : coordinatorHandler.getNodeEndpoints(nodeIeeeAddress)) { + List handlers = configFactory.getConfigHandlers(endpoint); + configHandlers.addAll(handlers); + } + + List nodeChannels; + + List parameters = new ArrayList<>( + ZigBeeConfigDescriptionParameters.getParameters()); + + if (getThing().getThingTypeUID().equals(ZigBeeBindingConstants.THING_TYPE_GENERIC_DEVICE)) { + // Dynamically create the channels from the device + // Process all the endpoints for this device and add all channels as derived from the supported clusters + nodeChannels = new ArrayList<>(); + for (ZigBeeEndpoint endpoint : coordinatorHandler.getNodeEndpoints(nodeIeeeAddress)) { + logger.debug("{}: Checking endpoint {} channels", nodeIeeeAddress, endpoint.getEndpointId()); + nodeChannels.addAll(channelFactory.getChannels(getThing().getUID(), endpoint)); + } + logger.debug("{}: Dynamically created {} channels", nodeIeeeAddress, nodeChannels.size()); + + for (ZclClusterConfigHandler handler : configHandlers) { + parameters.addAll(handler.getConfiguration()); + } + } else { + // We already have the correct thing type so just use the channels + nodeChannels = getThing().getChannels(); + logger.debug("{}: Using static definition with existing {} channels", nodeIeeeAddress, nodeChannels.size()); + } + + try { + configDescription = ConfigDescriptionBuilder.create(new URI("thing:" + getThing().getUID())) + .withParameters(parameters).build(); + } catch (IllegalArgumentException | URISyntaxException e) { + logger.debug("Error creating URI for thing description:", e); + } + + // Add statically defined endpoints and clusters + for (Channel channel : nodeChannels) { + // Process the channel properties + Map properties = channel.getProperties(); + int endpointId = Integer.parseInt(properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_ENDPOINT)); + ZigBeeEndpoint endpoint = node.getEndpoint(endpointId); + if (endpoint == null) { + int profileId; + if (properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_PROFILEID) == null) { + profileId = ZigBeeProfileType.ZIGBEE_HOME_AUTOMATION.getKey(); + } else { + profileId = Integer.parseInt(properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_PROFILEID)); + } + + logger.debug("{}: Creating statically defined device endpoint {} with profile {}", nodeIeeeAddress, + endpointId, ZigBeeProfileType.getByValue(profileId)); + endpoint = new ZigBeeEndpoint(node, endpointId); + endpoint.setProfileId(profileId); + node.addEndpoint(endpoint); + } + + List staticClusters; + boolean modified = false; + staticClusters = processClusterList(endpoint.getInputClusterIds(), + properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_INPUTCLUSTERS)); + if (!staticClusters.isEmpty()) { + logger.debug("{}: Forcing endpoint {} input clusters {}", nodeIeeeAddress, endpointId, staticClusters); + endpoint.setInputClusterIds(staticClusters); + modified = true; + } + + staticClusters = processClusterList(endpoint.getOutputClusterIds(), + properties.get(ZigBeeBindingConstants.CHANNEL_PROPERTY_OUTPUTCLUSTERS)); + if (!staticClusters.isEmpty()) { + logger.debug("{}: Forcing endpoint {} output clusters {}", nodeIeeeAddress, endpointId, staticClusters); + endpoint.setOutputClusterIds(staticClusters); + modified = true; + } + + if (modified) { + logger.debug("{}: Updating endpoint {}", nodeIeeeAddress, endpointId); + node.updateEndpoint(endpoint); + } + } + + try { + // Check if the channels we've discovered are the same + List oldChannelUidList = new ArrayList(); + for (Channel channel : getThing().getChannels()) { + oldChannelUidList.add(channel.getUID()); + } + List newChannelUidList = new ArrayList(); + for (Channel channel : nodeChannels) { + newChannelUidList.add(channel.getUID()); + + // Add the configuration from the existing channel into the new channel + Channel currentChannel = getThing().getChannel(channel.getUID().toString()); + if (currentChannel != null) { + channel.getConfiguration().setProperties(currentChannel.getConfiguration().getProperties()); + } + } + + if (!newChannelUidList.equals(oldChannelUidList)) { + logger.debug("{}: Updating thing definition as channels have changed from {} to {}", nodeIeeeAddress, + oldChannelUidList, newChannelUidList); + ThingBuilder thingBuilder = editThing(); + thingBuilder.withChannels(nodeChannels).withConfiguration(getConfig()); + updateThing(thingBuilder.build()); + } + + boolean doInitializeDevice = !Boolean + .parseBoolean(thing.getProperties().get(ZigBeeBindingConstants.THING_PROPERTY_DEVICE_INITIALIZED)); + if (doInitializeDevice) { + initializeDevice(); + } else { + logger.debug("{}: Device initialization will be skipped as the device is already initialized", + nodeIeeeAddress); + } + } catch (Exception e) { + logger.error("{}: Exception creating channels ", nodeIeeeAddress, e); + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR); + return; + } + + logger.debug("{}: Channel initialisation complete", nodeIeeeAddress); + } + + /** + * Process a static cluster list and add it to the existing list + * + * @param initialClusters a collection of existing clusters + * @param newClusters a string containing a comma separated list of clusters + * @return a list of clusters if the list is updated, or an empty list if it has not changed + */ + private List processClusterList(Collection initialClusters, String newClusters) { + if (newClusters == null || newClusters.length() == 0) { + return Collections.emptyList(); + } + + Set clusters = new HashSet(); + clusters.addAll(initialClusters); + return clusters.addAll( + Arrays.asList(newClusters.split(",")).stream().map(s -> Integer.valueOf(s)).collect(Collectors.toSet())) + ? new ArrayList(clusters) + : Collections.emptyList(); + } + +} diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeIsAliveTracker.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeIsAliveTracker.java index ecaf4c4cc..b6b977b40 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeIsAliveTracker.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeIsAliveTracker.java @@ -41,30 +41,30 @@ public class ZigBeeIsAliveTracker { private final Logger logger = LoggerFactory.getLogger(ZigBeeIsAliveTracker.class); - private Map handlerIntervalMapping = new ConcurrentHashMap<>(); - private Map> scheduledTasks = new ConcurrentHashMap<>(); - private Set lastChance = new HashSet<>(); + private Map handlerIntervalMapping = new ConcurrentHashMap<>(); + private Map> scheduledTasks = new ConcurrentHashMap<>(); + private Set lastChance = new HashSet<>(); protected final ScheduledExecutorService scheduler = ThreadPoolManager.getScheduledPool("ZigBeeIsAliveTracker"); /** - * Adds a mapping from {@link ZigBeeThingHandler} to the interval in which it should have communicated + * Adds a mapping from {@link ZigBeeBaseThingHandler} to the interval in which it should have communicated * - * @param zigBeeThingHandler the {@link ZigBeeThingHandler} + * @param zigBeeThingHandler the {@link ZigBeeBaseThingHandler} * @param expectedUpdateInterval the interval in which the device should have communicated with us */ - public void addHandler(ZigBeeThingHandler zigBeeThingHandler, int expectedUpdateInterval) { + public void addHandler(ZigBeeBaseThingHandler zigBeeThingHandler, int expectedUpdateInterval) { logger.debug("IsAlive Tracker added for thingUID={}", zigBeeThingHandler.getThing().getUID()); handlerIntervalMapping.put(zigBeeThingHandler, expectedUpdateInterval); resetTimer(zigBeeThingHandler); } /** - * Removes a {@link ZigBeeThingHandler} from the map so it is not tracked anymore + * Removes a {@link ZigBeeBaseThingHandler} from the map so it is not tracked anymore * - * @param zigBeeThingHandler the {@link ZigBeeThingHandler} + * @param zigBeeThingHandler the {@link ZigBeeBaseThingHandler} */ - public void removeHandler(ZigBeeThingHandler zigBeeThingHandler) { + public void removeHandler(ZigBeeBaseThingHandler zigBeeThingHandler) { logger.debug("IsAlive Tracker removed for thingUID={}", zigBeeThingHandler.getThing().getUID()); cancelTask(zigBeeThingHandler); lastChance.remove(zigBeeThingHandler); @@ -72,11 +72,12 @@ public void removeHandler(ZigBeeThingHandler zigBeeThingHandler) { } /** - * Reset the timer for a {@link ZigBeeThingHandler}, i.e. expressing that some communication has just occurred + * Reset the timer for a {@link ZigBeeBaseThingHandler}, i.e. expressing that some communication has just + * occurred * - * @param zigBeeThingHandler the {@link ZigBeeThingHandler} + * @param zigBeeThingHandler the {@link ZigBeeBaseThingHandler} */ - public synchronized void resetTimer(ZigBeeThingHandler zigBeeThingHandler) { + public synchronized void resetTimer(ZigBeeBaseThingHandler zigBeeThingHandler) { logger.debug("IsAlive Tracker reset for handler with thingUID={}", zigBeeThingHandler.getThing().getUID()); cancelTask(zigBeeThingHandler); ScheduledFuture existingTask = scheduledTasks.get(zigBeeThingHandler); @@ -88,7 +89,7 @@ public synchronized void resetTimer(ZigBeeThingHandler zigBeeThingHandler) { } } - private void scheduleTask(ZigBeeThingHandler handler, int interval) { + private void scheduleTask(ZigBeeBaseThingHandler handler, int interval) { ScheduledFuture task = scheduler.schedule(() -> { synchronized (lastChance) { scheduledTasks.remove(handler); @@ -114,7 +115,7 @@ private void scheduleTask(ZigBeeThingHandler handler, int interval) { scheduledTasks.put(handler, task); } - private void cancelTask(ZigBeeThingHandler handler) { + private void cancelTask(ZigBeeBaseThingHandler handler) { lastChance.remove(handler); ScheduledFuture task = scheduledTasks.get(handler); if (task != null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeDeviceConfigHandler.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeDeviceConfigHandler.java index 28a5345d5..c29c8f054 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeDeviceConfigHandler.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeDeviceConfigHandler.java @@ -18,7 +18,7 @@ import org.eclipse.jdt.annotation.NonNull; import org.openhab.core.config.core.Configuration; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,7 +28,7 @@ import com.zsmartsystems.zigbee.zcl.protocol.ZclDataType; /** - * Class to handle ZigBee device configuration. This is a helper class used by the {@link ZigBeeThingHandler} for + * Class to handle ZigBee device configuration. This is a helper class used by the {@link ZigBeeGenericThingHandler} for * managing device configuration. * * @author Chris Jackson - Initial Contribution diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeHandlerFactory.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeHandlerFactory.java index 3833130b0..852cbd4e9 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeHandlerFactory.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeHandlerFactory.java @@ -23,7 +23,8 @@ import org.openhab.core.thing.type.DynamicStateDescriptionProvider; import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.discovery.ZigBeeThingTypeMatcher; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.binding.zigbee.handler.ZigBeeIsAliveTracker; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @@ -60,7 +61,7 @@ protected ThingHandler createHandler(Thing thing) { return null; } - ZigBeeThingHandler handler = new ZigBeeThingHandler(thing, zigbeeChannelConverterFactory, zigbeeIsAliveTracker); + ZigBeeGenericThingHandler handler = new ZigBeeGenericThingHandler(thing, zigbeeChannelConverterFactory, zigbeeIsAliveTracker); bundleContext.registerService(ConfigDescriptionProvider.class.getName(), handler, new Hashtable()); bundleContext.registerService(DynamicStateDescriptionProvider.class.getName(), handler, diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterAtmosphericPressure.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterAtmosphericPressure.java index 3f7e97a43..98537aa65 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterAtmosphericPressure.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterAtmosphericPressure.java @@ -22,14 +22,14 @@ import javax.measure.quantity.Pressure; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.unit.SIUnits; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -110,7 +110,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclPressureMeasurementCluster) endpoint.getInputCluster(ZclPressureMeasurementCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryAlarm.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryAlarm.java index 6fdf24b1b..dcbf330ea 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryAlarm.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryAlarm.java @@ -20,13 +20,13 @@ import java.util.Set; import java.util.concurrent.ExecutionException; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.StringType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -116,7 +116,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclPowerConfigurationCluster) endpoint.getInputCluster(ZclPowerConfigurationCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryPercent.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryPercent.java index f32ca59b3..e4848c645 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryPercent.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryPercent.java @@ -18,13 +18,13 @@ import java.util.Set; import java.util.concurrent.ExecutionException; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.DecimalType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,7 +89,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclPowerConfigurationCluster) endpoint.getInputCluster(ZclPowerConfigurationCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryVoltage.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryVoltage.java index 2a9674479..85e54dc70 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryVoltage.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryVoltage.java @@ -19,14 +19,14 @@ import javax.measure.quantity.ElectricPotential; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; 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.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -86,7 +86,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclPowerConfigurationCluster) endpoint.getInputCluster(ZclPowerConfigurationCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBinaryInput.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBinaryInput.java index 87a24da88..77c33463c 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBinaryInput.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBinaryInput.java @@ -16,13 +16,13 @@ import java.util.Set; import java.util.concurrent.ExecutionException; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.OnOffType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -81,7 +81,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); binaryInputCluster = (ZclBinaryInputBasicCluster) endpoint .getInputCluster(ZclBinaryInputBasicCluster.CLUSTER_ID); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColor.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColor.java index 866320b58..a5be02ff1 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColor.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColor.java @@ -27,6 +27,10 @@ import java.util.stream.Stream; 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.ZigBeeBaseThingHandler; +import org.openhab.binding.zigbee.internal.converter.config.ZclLevelControlConfig; import org.openhab.core.config.core.Configuration; import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.HSBType; @@ -37,10 +41,6 @@ import org.openhab.core.thing.binding.builder.ChannelBuilder; import org.openhab.core.types.Command; import org.openhab.core.types.UnDefType; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; -import org.openhab.binding.zigbee.internal.converter.config.ZclLevelControlConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -209,7 +209,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); colorUpdateScheduler = Executors.newSingleThreadScheduledExecutor(); 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 73f90b9ef..d5523d355 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 @@ -18,6 +18,9 @@ import java.util.Set; import java.util.concurrent.ExecutionException; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.PercentType; import org.openhab.core.thing.Channel; @@ -25,9 +28,6 @@ import org.openhab.core.thing.binding.builder.ChannelBuilder; import org.openhab.core.types.Command; import org.openhab.core.types.UnDefType; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -107,7 +107,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); clusterColorControl = (ZclColorControlCluster) endpoint.getInputCluster(ZclColorControlCluster.CLUSTER_ID); if (clusterColorControl == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterDoorLock.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterDoorLock.java index 3ae368807..fc5a5f86e 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterDoorLock.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterDoorLock.java @@ -18,7 +18,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.OnOffType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; @@ -87,7 +87,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclDoorLockCluster) endpoint.getInputCluster(ZclDoorLockCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterFanControl.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterFanControl.java index a1c247a2c..a2eb71e35 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterFanControl.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterFanControl.java @@ -23,7 +23,7 @@ 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.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.binding.zigbee.internal.converter.config.ZclFanControlConfig; import org.openhab.core.config.core.Configuration; import org.openhab.core.library.types.DecimalType; @@ -102,7 +102,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclFanControlCluster) endpoint.getInputCluster(ZclFanControlCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterGenericButton.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterGenericButton.java index f9083e136..0e5cf9c5b 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterGenericButton.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterGenericButton.java @@ -29,11 +29,11 @@ import java.util.function.Function; import java.util.function.Predicate; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.CommonTriggerEvents; import org.openhab.core.thing.ThingUID; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -84,7 +84,7 @@ public Set getImplementedServerClusters() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); for (ButtonPressType buttonPressType : ButtonPressType.values()) { EventSpec eventSpec = parseEventSpec(channel.getProperties(), buttonPressType); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIas.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIas.java index a8666cc54..5dda999bb 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIas.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIas.java @@ -18,10 +18,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OpenClosedType; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -104,7 +104,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); logger.debug("{}: Initialising device IAS Zone cluster for {}", endpoint.getIeeeAddress(), channel.getChannelTypeUID()); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasCieSystem.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasCieSystem.java index c86802113..0cda6db90 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasCieSystem.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasCieSystem.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.zigbee.internal.converter; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.clusters.iaszone.ZoneTypeEnum; @@ -29,7 +29,7 @@ */ public class ZigBeeConverterIasCieSystem extends ZigBeeConverterIas { @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { bitTest = CIE_ALARM1; return super.initializeConverter(thing); } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasCoDetector.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasCoDetector.java index dbfd3e6ba..6d4d0bf79 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasCoDetector.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasCoDetector.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.zigbee.internal.converter; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.clusters.iaszone.ZoneTypeEnum; @@ -29,7 +29,7 @@ */ public class ZigBeeConverterIasCoDetector extends ZigBeeConverterIas { @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { bitTest = CIE_ALARM1; return super.initializeConverter(thing); } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasContactPortal1.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasContactPortal1.java index a68542b07..b0d951d95 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasContactPortal1.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasContactPortal1.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.zigbee.internal.converter; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.clusters.iaszone.ZoneTypeEnum; @@ -29,7 +29,7 @@ */ public class ZigBeeConverterIasContactPortal1 extends ZigBeeConverterIas { @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { bitTest = CIE_ALARM1; return super.initializeConverter(thing); } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasFireIndicator.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasFireIndicator.java index 3966e02b3..5d1d5c0bc 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasFireIndicator.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasFireIndicator.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.zigbee.internal.converter; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.clusters.iaszone.ZoneTypeEnum; @@ -29,7 +29,7 @@ */ public class ZigBeeConverterIasFireIndicator extends ZigBeeConverterIas { @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { bitTest = CIE_ALARM1; return super.initializeConverter(thing); } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasLowBattery.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasLowBattery.java index 0195d78b4..fd00271ba 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasLowBattery.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasLowBattery.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.zigbee.internal.converter; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import com.zsmartsystems.zigbee.ZigBeeEndpoint; @@ -28,7 +28,7 @@ public class ZigBeeConverterIasLowBattery extends ZigBeeConverterIas { @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { bitTest = CIE_BATTERY; return super.initializeConverter(thing); } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMotionIntrusion.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMotionIntrusion.java index 266cf80dc..4cbfc235f 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMotionIntrusion.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMotionIntrusion.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.zigbee.internal.converter; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.clusters.iaszone.ZoneTypeEnum; @@ -29,7 +29,7 @@ */ public class ZigBeeConverterIasMotionIntrusion extends ZigBeeConverterIas { @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { bitTest = CIE_ALARM1; return super.initializeConverter(thing); } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMotionPresence.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMotionPresence.java index 1d416c0b1..8f9ea78ef 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMotionPresence.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMotionPresence.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.zigbee.internal.converter; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.clusters.iaszone.ZoneTypeEnum; @@ -29,7 +29,7 @@ */ public class ZigBeeConverterIasMotionPresence extends ZigBeeConverterIas { @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { bitTest = CIE_ALARM2; return super.initializeConverter(thing); } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMovement.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMovement.java index b18c28699..02e1c9d91 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMovement.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasMovement.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.zigbee.internal.converter; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.clusters.iaszone.ZoneTypeEnum; @@ -29,7 +29,7 @@ public class ZigBeeConverterIasMovement extends ZigBeeConverterIas { @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { bitTest = CIE_ALARM1; return super.initializeConverter(thing); } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasTamper.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasTamper.java index 2961c661e..fdc23a3c7 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasTamper.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasTamper.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.zigbee.internal.converter; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import com.zsmartsystems.zigbee.ZigBeeEndpoint; @@ -28,7 +28,7 @@ public class ZigBeeConverterIasTamper extends ZigBeeConverterIas { @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { bitTest = CIE_TAMPER; return super.initializeConverter(thing); } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasVibration.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasVibration.java index 329a73154..a8a2a7827 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasVibration.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasVibration.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.zigbee.internal.converter; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.clusters.iaszone.ZoneTypeEnum; @@ -29,7 +29,7 @@ public class ZigBeeConverterIasVibration extends ZigBeeConverterIas { @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { bitTest = CIE_ALARM2; return super.initializeConverter(thing); } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasWaterSensor.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasWaterSensor.java index 0f68b45af..c42493f8b 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasWaterSensor.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasWaterSensor.java @@ -12,11 +12,11 @@ */ package org.openhab.binding.zigbee.internal.converter; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import com.zsmartsystems.zigbee.ZigBeeEndpoint; import com.zsmartsystems.zigbee.zcl.clusters.iaszone.ZoneTypeEnum; @@ -29,7 +29,7 @@ */ public class ZigBeeConverterIasWaterSensor extends ZigBeeConverterIas { @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { bitTest = CIE_ALARM1; return super.initializeConverter(thing); } 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 de435e926..529725c92 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 @@ -20,15 +20,15 @@ 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.ZigBeeBaseThingHandler; +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.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; -import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -96,7 +96,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclIlluminanceMeasurementCluster) endpoint .getInputCluster(ZclIlluminanceMeasurementCluster.CLUSTER_ID); 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 dad0855d8..26be48181 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 @@ -19,14 +19,14 @@ import javax.measure.quantity.Power; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; 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.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,7 +92,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); clusterMeasurement = (ZclElectricalMeasurementCluster) endpoint .getInputCluster(ZclElectricalMeasurementCluster.CLUSTER_ID); 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 a9b503511..d2a998496 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 @@ -19,14 +19,14 @@ import javax.measure.quantity.ElectricCurrent; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; 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.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,7 +93,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); clusterMeasurement = (ZclElectricalMeasurementCluster) endpoint .getInputCluster(ZclElectricalMeasurementCluster.CLUSTER_ID); 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 7a6dc7bf6..0c4a1663c 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 @@ -19,14 +19,14 @@ import javax.measure.quantity.ElectricPotential; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; 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.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,7 +93,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); clusterMeasurement = (ZclElectricalMeasurementCluster) endpoint .getInputCluster(ZclElectricalMeasurementCluster.CLUSTER_ID); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringInstantaneousDemand.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringInstantaneousDemand.java index 4c0a9e784..cae0d60f0 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringInstantaneousDemand.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringInstantaneousDemand.java @@ -19,7 +19,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.DecimalType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; @@ -92,7 +92,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); clusterMetering = (ZclMeteringCluster) endpoint.getInputCluster(ZclMeteringCluster.CLUSTER_ID); if (clusterMetering == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationDelivered.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationDelivered.java index d98cff649..62c56c2b7 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationDelivered.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationDelivered.java @@ -19,7 +19,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.DecimalType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; @@ -92,7 +92,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); clusterMetering = (ZclMeteringCluster) endpoint.getInputCluster(ZclMeteringCluster.CLUSTER_ID); if (clusterMetering == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationReceived.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationReceived.java index 9bc91093c..9aecd2d71 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationReceived.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationReceived.java @@ -19,7 +19,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.DecimalType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; @@ -92,7 +92,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); clusterMetering = (ZclMeteringCluster) endpoint.getInputCluster(ZclMeteringCluster.CLUSTER_ID); if (clusterMetering == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterOccupancy.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterOccupancy.java index 614a1150a..48ed4d687 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterOccupancy.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterOccupancy.java @@ -16,13 +16,13 @@ import java.util.Set; import java.util.concurrent.ExecutionException; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.OnOffType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -81,7 +81,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); clusterOccupancy = (ZclOccupancySensingCluster) endpoint.getInputCluster(ZclOccupancySensingCluster.CLUSTER_ID); if (clusterOccupancy == null) { 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 d353fecf4..2f6c02639 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 @@ -17,13 +17,13 @@ import java.util.Set; import java.util.concurrent.ExecutionException; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.DecimalType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -81,7 +81,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclRelativeHumidityMeasurementCluster) endpoint .getInputCluster(ZclRelativeHumidityMeasurementCluster.CLUSTER_ID); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevel.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevel.java index 60e3e8189..10f2ca9b8 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevel.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevel.java @@ -28,7 +28,7 @@ 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.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.binding.zigbee.internal.converter.config.ZclLevelControlConfig; import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; import org.openhab.core.config.core.Configuration; @@ -233,7 +233,7 @@ private boolean initializeDeviceClient() { } @Override - public synchronized boolean initializeConverter(ZigBeeThingHandler thing) { + public synchronized boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); updateScheduler = Executors.newSingleThreadScheduledExecutor(); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoff.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoff.java index 8930f4da4..d2e9f6b38 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoff.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoff.java @@ -26,7 +26,7 @@ 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.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.binding.zigbee.internal.converter.config.ZclOnOffSwitchConfig; import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; import org.openhab.core.config.core.Configuration; @@ -135,7 +135,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); updateScheduler = Executors.newSingleThreadScheduledExecutor(); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTemperature.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTemperature.java index 727e151a9..4f1c055c9 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTemperature.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTemperature.java @@ -16,13 +16,13 @@ import java.util.Set; import java.util.concurrent.ExecutionException; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; 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.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,7 +93,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclTemperatureMeasurementCluster) endpoint .getInputCluster(ZclTemperatureMeasurementCluster.CLUSTER_ID); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatLocalTemperature.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatLocalTemperature.java index 9cc2bffaf..8668c32b7 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatLocalTemperature.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatLocalTemperature.java @@ -18,7 +18,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; @@ -85,7 +85,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclThermostatCluster) endpoint.getInputCluster(ZclThermostatCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedCooling.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedCooling.java index c0b9ae4d8..7185dce63 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedCooling.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedCooling.java @@ -18,7 +18,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; @@ -87,7 +87,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclThermostatCluster) endpoint.getInputCluster(ZclThermostatCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedHeating.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedHeating.java index a2a6c69e9..b01475c5a 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedHeating.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedHeating.java @@ -18,7 +18,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; @@ -83,7 +83,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclThermostatCluster) endpoint.getInputCluster(ZclThermostatCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOutdoorTemperature.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOutdoorTemperature.java index 95cbc31ac..7b752e2a2 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOutdoorTemperature.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOutdoorTemperature.java @@ -18,7 +18,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; @@ -83,7 +83,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclThermostatCluster) endpoint.getInputCluster(ZclThermostatCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatRunningMode.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatRunningMode.java index 44ab36e19..bc4496612 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatRunningMode.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatRunningMode.java @@ -18,7 +18,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.DecimalType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; @@ -89,7 +89,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclThermostatCluster) endpoint.getInputCluster(ZclThermostatCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatSystemMode.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatSystemMode.java index c052192be..0ae23aca8 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatSystemMode.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatSystemMode.java @@ -21,7 +21,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.OnOffType; import org.openhab.core.thing.Channel; @@ -96,7 +96,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclThermostatCluster) endpoint.getInputCluster(ZclThermostatCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedCooling.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedCooling.java index 56006cfd2..a192ff42d 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedCooling.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedCooling.java @@ -18,7 +18,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; @@ -84,7 +84,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclThermostatCluster) endpoint.getInputCluster(ZclThermostatCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedHeating.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedHeating.java index cd1fdf8dd..e1c4e7e40 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedHeating.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedHeating.java @@ -18,7 +18,7 @@ import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.builder.ChannelBuilder; @@ -86,7 +86,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); cluster = (ZclThermostatCluster) endpoint.getInputCluster(ZclThermostatCluster.CLUSTER_ID); if (cluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterWindowCoveringLift.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterWindowCoveringLift.java index aece389d1..52c0fb05c 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterWindowCoveringLift.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterWindowCoveringLift.java @@ -17,6 +17,10 @@ import java.util.Set; import java.util.concurrent.ExecutionException; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; +import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; import org.openhab.core.library.types.PercentType; import org.openhab.core.library.types.StopMoveType; import org.openhab.core.library.types.UpDownType; @@ -25,10 +29,6 @@ import org.openhab.core.thing.binding.builder.ChannelBuilder; import org.openhab.core.thing.type.AutoUpdatePolicy; import org.openhab.core.types.Command; -import org.openhab.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; -import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -101,7 +101,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); clusterServer = (ZclWindowCoveringCluster) endpoint.getInputCluster(ZclWindowCoveringCluster.CLUSTER_ID); if (clusterServer == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDevice.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDevice.java index 118cc4013..0bc8f6657 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDevice.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDevice.java @@ -23,17 +23,17 @@ import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNull; +import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; +import org.openhab.binding.zigbee.converter.warningdevice.SquawkType; +import org.openhab.binding.zigbee.converter.warningdevice.WarningType; +import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; import org.openhab.core.config.core.Configuration; import org.openhab.core.library.types.StringType; 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.binding.zigbee.ZigBeeBindingConstants; -import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; -import org.openhab.binding.zigbee.converter.warningdevice.SquawkType; -import org.openhab.binding.zigbee.converter.warningdevice.WarningType; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -70,7 +70,7 @@ public boolean initializeDevice() { } @Override - public boolean initializeConverter(ZigBeeThingHandler thing) { + public boolean initializeConverter(ZigBeeBaseThingHandler thing) { super.initializeConverter(thing); iasWdCluster = (ZclIasWdCluster) endpoint.getInputCluster(ZclIasWdCluster.CLUSTER_ID); if (iasWdCluster == null) { diff --git a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumiremoteb286acn01.xml b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumiremoteb286acn01.xml index 83fb4aa65..b3171abe6 100644 --- a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumiremoteb286acn01.xml +++ b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumiremoteb286acn01.xml @@ -53,12 +53,6 @@ - - Xiaomi - lumi.remote.b286acn01 - END_DEVICE - - zigbee_macaddress diff --git a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor-magnet.xml b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor-magnet.xml index 1ea342656..64b87cbed 100644 --- a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor-magnet.xml +++ b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor-magnet.xml @@ -20,12 +20,6 @@ - - Xiaomi - lumi.sensor_magnet - END_DEVICE - - zigbee_macaddress diff --git a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor-motion.xml b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor-motion.xml index 16573ee0b..40b94d894 100644 --- a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor-motion.xml +++ b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor-motion.xml @@ -17,12 +17,6 @@ - - Xiaomi - lumi.sensor_motion - END_DEVICE - - zigbee_macaddress diff --git a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/xiaomi_lumisensor-switchaq2.xml b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor-switchaq2.xml similarity index 90% rename from org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/xiaomi_lumisensor-switchaq2.xml rename to org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor-switchaq2.xml index 170df6157..4ce153a66 100644 --- a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/xiaomi_lumisensor-switchaq2.xml +++ b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor-switchaq2.xml @@ -33,12 +33,6 @@ - - Xiaomi - lumi.sensor_switch.aq2 - END_DEVICE - - zigbee_macaddress diff --git a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor86sw2.xml b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor86sw2.xml index 1c3cfbc2c..be39b90b2 100644 --- a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor86sw2.xml +++ b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensor86sw2.xml @@ -31,12 +31,6 @@ - - Xiaomi - lumi.sensor_86sw2 - END_DEVICE - - zigbee_macaddress diff --git a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensorht.xml b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensorht.xml index aa6ddfc74..21f5ffa6a 100644 --- a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensorht.xml +++ b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumisensorht.xml @@ -23,12 +23,6 @@ - - Xiaomi - lumi.sensor_ht - END_DEVICE - - zigbee_macaddress diff --git a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumiwleak-aq1.xml b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumiwleak-aq1.xml index 0b03bdbe7..4793628c7 100644 --- a/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumiwleak-aq1.xml +++ b/org.openhab.binding.zigbee/src/main/resources/OH-INF/thing/xiaomi/lumiwleak-aq1.xml @@ -17,12 +17,6 @@ - - Xiaomi - lumi.sensor_wleak.aq1 - END_DEVICE - - zigbee_macaddress diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/discovery/internal/ZigBeeDefaultDiscoveryParticipantTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/discovery/internal/ZigBeeDefaultDiscoveryParticipantTest.java index b16068df3..82c40b5c5 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/discovery/internal/ZigBeeDefaultDiscoveryParticipantTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/discovery/internal/ZigBeeDefaultDiscoveryParticipantTest.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; -import org.openhab.binding.zigbee.internal.ZigBeeThingTypeMatcher; +import org.openhab.binding.zigbee.discovery.ZigBeeThingTypeMatcher; import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingUID; diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandlerTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandlerTest.java index 354b4bef4..a7986d33f 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandlerTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandlerTest.java @@ -58,9 +58,9 @@ private List processClusterList(Collection initialClusters, St SecurityException { Method privateMethod; - ZigBeeThingHandler handler = new ZigBeeThingHandler(null, null, null); + ZigBeeGenericThingHandler handler = new ZigBeeGenericThingHandler(null, null, null); - privateMethod = ZigBeeThingHandler.class.getDeclaredMethod("processClusterList", Collection.class, + privateMethod = ZigBeeGenericThingHandler.class.getDeclaredMethod("processClusterList", Collection.class, String.class); privateMethod.setAccessible(true); @@ -155,13 +155,13 @@ private void testInitializeDevice(String deviceInitializedProperty) ZigBeeIsAliveTracker zigBeeIsAliveTracker = mock(ZigBeeIsAliveTracker.class); - ZigBeeThingHandler zigBeeThingHandler = new ZigBeeThingHandler(thing, zigBeeChannelConverterFactory, + ZigBeeGenericThingHandler zigBeeThingHandler = new ZigBeeGenericThingHandler(thing, zigBeeChannelConverterFactory, zigBeeIsAliveTracker); injectIntoPrivateField(zigBeeThingHandler, zigBeeCoordinatorHandler, "coordinatorHandler"); injectIntoPrivateField(zigBeeThingHandler, ieeeAddress, "nodeIeeeAddress"); // call doNodeInitialisation by reflection as it is not accessible - Method doNodeInitialisationMethod = ZigBeeThingHandler.class.getDeclaredMethod("doNodeInitialisation", + Method doNodeInitialisationMethod = ZigBeeGenericThingHandler.class.getDeclaredMethod("doNodeInitialisation", (Class[]) null); doNodeInitialisationMethod.setAccessible(true); doNodeInitialisationMethod.invoke(zigBeeThingHandler, (Object[]) null); @@ -191,7 +191,7 @@ private ZigBeeChannelConverterFactory mockZigBeeChannelConverterFactory( private ZigBeeBaseChannelConverter mockZigBeeBaseChannelConverterSuccessfull() { ZigBeeBaseChannelConverter zigBeeChannelConverter = mock(ZigBeeBaseChannelConverter.class); when(zigBeeChannelConverter.initializeDevice()).thenReturn(true); - when(zigBeeChannelConverter.initializeConverter(any(ZigBeeThingHandler.class))).thenReturn(true); + when(zigBeeChannelConverter.initializeConverter(any(ZigBeeGenericThingHandler.class))).thenReturn(true); return zigBeeChannelConverter; } @@ -245,7 +245,7 @@ private ZigBeeNode mockZigBeeNode(int endpointId, IeeeAddress ieeeAddress) private void injectIntoPrivateField(Object object, Object value, String fieldname) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { - Field coordinatorHandlerField = ZigBeeThingHandler.class.getDeclaredField(fieldname); + Field coordinatorHandlerField = ZigBeeGenericThingHandler.class.getDeclaredField(fieldname); coordinatorHandlerField.setAccessible(true); coordinatorHandlerField.set(object, value); } diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/ZigBeeThingTypeMatcherTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/ZigBeeThingTypeMatcherTest.java index 71b1bae6b..ae7848d26 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/ZigBeeThingTypeMatcherTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/ZigBeeThingTypeMatcherTest.java @@ -18,6 +18,7 @@ import java.util.Map; import org.junit.jupiter.api.Test; +import org.openhab.binding.zigbee.discovery.ZigBeeThingTypeMatcher; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingTypeUID; diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterAtmosphericPressureTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterAtmosphericPressureTest.java index e0446296f..708d23214 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterAtmosphericPressureTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterAtmosphericPressureTest.java @@ -22,7 +22,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.unit.SIUnits; import org.openhab.core.thing.Channel; @@ -54,7 +54,7 @@ public void testAttributeUpdated() { ZigBeeConverterAtmosphericPressure converter = new ZigBeeConverterAtmosphericPressure(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d"), "").build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); converter.initializeConverter(thingHandler); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryAlarmTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryAlarmTest.java index 07d105296..b5ad66ea8 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryAlarmTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterBatteryAlarmTest.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.library.types.StringType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; @@ -42,7 +42,7 @@ public class ZigBeeConverterBatteryAlarmTest { private ZigBeeConverterBatteryAlarm converter; - private ZigBeeThingHandler thingHandler; + private ZigBeeGenericThingHandler thingHandler; private Channel channel; private ZigBeeCoordinatorHandler coordinatorHandler; private ZigBeeEndpoint endpoint; @@ -54,7 +54,7 @@ public void setup() { endpoint = mock(ZigBeeEndpoint.class); channel = mock(Channel.class); - thingHandler = mock(ZigBeeThingHandler.class); + thingHandler = mock(ZigBeeGenericThingHandler.class); coordinatorHandler = mock(ZigBeeCoordinatorHandler.class); when(coordinatorHandler.getEndpoint(ieeeAddress, endpointId)).thenReturn(endpoint); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColorTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColorTest.java index 66fe93bba..91e5c53f4 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColorTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColorTest.java @@ -19,7 +19,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.library.types.HSBType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; @@ -56,7 +56,7 @@ public void testAttributeUpdated() { ZigBeeConverterColorColor converter = new ZigBeeConverterColorColor(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d"), "").build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); converter.initializeConverter(thingHandler); @@ -121,7 +121,7 @@ public void testAttributeNotUpdatedWhenColorModeIsColorTemperature() { ZigBeeConverterColorColor converter = new ZigBeeConverterColorColor(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d"), "").build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); converter.initializeConverter(thingHandler); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureTest.java index 181730d86..47194927c 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperatureTest.java @@ -23,7 +23,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.library.types.PercentType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; @@ -131,7 +131,7 @@ public void testAttributeNotUpdatedWhenColorModeIsNotColorTemperature() { ZigBeeConverterColorTemperature converter = getConverter(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d"), "").build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); converter.initializeConverter(thingHandler); @@ -178,7 +178,7 @@ public void testAttributeUpdatedWhenColorModeIsNull() { ZigBeeConverterColorTemperature converter = getConverter(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d"), "").build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); converter.initializeConverter(thingHandler); @@ -206,7 +206,7 @@ public void testAttributeUpdatedWhenColorModeIsColorTemperature() { ZigBeeConverterColorTemperature converter = getConverter(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d"), "").build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); converter.initializeConverter(thingHandler); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterGenericButtonTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterGenericButtonTest.java index b80aab907..f50b73eed 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterGenericButtonTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterGenericButtonTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.CommonTriggerEvents; import org.openhab.core.thing.ThingUID; @@ -52,7 +52,7 @@ public class ZigBeeConverterGenericButtonTest { private ZigBeeConverterGenericButton converter; - private ZigBeeThingHandler thingHandler; + private ZigBeeGenericThingHandler thingHandler; private Channel channel; private ZigBeeCoordinatorHandler coordinatorHandler; private ZigBeeEndpoint endpoint; @@ -65,7 +65,7 @@ public void setup() { int endpointId = 1; endpoint = mock(ZigBeeEndpoint.class); - thingHandler = mock(ZigBeeThingHandler.class); + thingHandler = mock(ZigBeeGenericThingHandler.class); channel = mock(Channel.class); channelProperties = new HashMap<>(); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasTamperTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasTamperTest.java index 6ac25dffb..320b642d0 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasTamperTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterIasTamperTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import org.openhab.binding.zigbee.ZigBeeBindingConstants; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ThingUID; @@ -42,7 +42,7 @@ public class ZigBeeConverterIasTamperTest { private ZigBeeConverterIasTamper converter; - private ZigBeeThingHandler thingHandler; + private ZigBeeGenericThingHandler thingHandler; private Channel channel; private ZigBeeCoordinatorHandler coordinatorHandler; private ZigBeeEndpoint endpoint; @@ -71,7 +71,7 @@ public void setup() throws InterruptedException, ExecutionException { when(reportingFuture.get()).thenReturn(reportingResult); channel = mock(Channel.class); - thingHandler = mock(ZigBeeThingHandler.class); + thingHandler = mock(ZigBeeGenericThingHandler.class); coordinatorHandler = mock(ZigBeeCoordinatorHandler.class); when(coordinatorHandler.getEndpoint(ieeeAddress, endpointId)).thenReturn(endpoint); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringInstantaneousDemandTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringInstantaneousDemandTest.java index a8fda6e66..21f0d181a 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringInstantaneousDemandTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringInstantaneousDemandTest.java @@ -19,7 +19,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.library.types.DecimalType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; @@ -62,7 +62,7 @@ public void testAttributeUpdated() { ZigBeeConverterMeteringInstantaneousDemand converter = new ZigBeeConverterMeteringInstantaneousDemand(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d"), "").build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); converter.initializeConverter(thingHandler); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationDeliveredTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationDeliveredTest.java index bb5ebd364..2f4ae28bf 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationDeliveredTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationDeliveredTest.java @@ -19,7 +19,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.library.types.DecimalType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; @@ -58,7 +58,7 @@ public void testAttributeUpdated() { ZigBeeConverterMeteringSummationDelivered converter = new ZigBeeConverterMeteringSummationDelivered(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d"), "").build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); converter.initializeConverter(thingHandler); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationReceivedTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationReceivedTest.java index b9f599028..533494e2f 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationReceivedTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterMeteringSummationReceivedTest.java @@ -19,7 +19,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.library.types.DecimalType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; @@ -62,7 +62,7 @@ public void testAttributeUpdated() { ZigBeeConverterMeteringSummationReceived converter = new ZigBeeConverterMeteringSummationReceived(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d"), "").build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); converter.initializeConverter(thingHandler); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevelTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevelTest.java index bd4246242..5313472da 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevelTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevelTest.java @@ -19,7 +19,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.PercentType; import org.openhab.core.thing.Channel; @@ -52,7 +52,7 @@ public void testAttributeUpdated() { ZigBeeConverterSwitchLevel converter = new ZigBeeConverterSwitchLevel(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d"), "").build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); converter.initializeConverter(thingHandler); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoffTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoffTest.java index 6f13820ae..759c4831a 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoffTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoffTest.java @@ -19,7 +19,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.library.types.OnOffType; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; @@ -50,7 +50,7 @@ public void testAttributeUpdated() { ZigBeeConverterSwitchOnoff converter = new ZigBeeConverterSwitchOnoff(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d")).build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTemperatureTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTemperatureTest.java index c1cfda174..178eff955 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTemperatureTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterTemperatureTest.java @@ -21,7 +21,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.unit.SIUnits; import org.openhab.core.thing.Channel; @@ -56,7 +56,7 @@ public void testAttributeUpdated() { ZigBeeConverterTemperature converter = new ZigBeeConverterTemperature(); ArgumentCaptor channelCapture = ArgumentCaptor.forClass(ChannelUID.class); ArgumentCaptor stateCapture = ArgumentCaptor.forClass(State.class); - ZigBeeThingHandler thingHandler = Mockito.mock(ZigBeeThingHandler.class); + ZigBeeGenericThingHandler thingHandler = Mockito.mock(ZigBeeGenericThingHandler.class); Channel channel = ChannelBuilder.create(new ChannelUID("a:b:c:d"), "").build(); converter.initialize(channel, coordinatorHandler, new IeeeAddress("1234567890ABCDEF"), 1); converter.initializeConverter(thingHandler); diff --git a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDeviceTest.java b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDeviceTest.java index 8fc06025f..88842a905 100644 --- a/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDeviceTest.java +++ b/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDeviceTest.java @@ -26,7 +26,7 @@ import org.openhab.binding.zigbee.converter.warningdevice.WarningMode; import org.openhab.binding.zigbee.converter.warningdevice.WarningType; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; -import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.StringType; import org.openhab.core.thing.Channel; @@ -44,7 +44,7 @@ public class ZigBeeConverterWarningDeviceTest { private ZigBeeConverterWarningDevice converter; - private ZigBeeThingHandler thingHandler; + private ZigBeeGenericThingHandler thingHandler; private Channel channel; private ZigBeeCoordinatorHandler coordinatorHandler; private ZigBeeEndpoint endpoint; @@ -58,7 +58,7 @@ public void setup() { endpoint = mock(ZigBeeEndpoint.class); channel = mock(Channel.class); - thingHandler = mock(ZigBeeThingHandler.class); + thingHandler = mock(ZigBeeGenericThingHandler.class); cluster = mock(ZclIasWdCluster.class); coordinatorHandler = mock(ZigBeeCoordinatorHandler.class);