Skip to content

Commit

Permalink
Update remaining converters, handlers and factories
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <[email protected]>
  • Loading branch information
cdjackson committed Nov 23, 2019
1 parent 02ce2fe commit e5abeb8
Show file tree
Hide file tree
Showing 30 changed files with 392 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.eclipse.smarthome.core.thing.Bridge;
import org.openhab.binding.zigbee.cc2531.internal.CC2531Configuration;
import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory;
import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler;
import org.openhab.binding.zigbee.handler.ZigBeeSerialPort;
import org.slf4j.Logger;
Expand All @@ -32,7 +33,6 @@
import com.zsmartsystems.zigbee.transport.ZigBeeTransportTransmit;
import com.zsmartsystems.zigbee.zcl.clusters.ZclIasZoneCluster;


/**
* The {@link CC2531Handler} is responsible for handling commands, which are
* sent to one of the channels.
Expand All @@ -43,8 +43,8 @@
public class CC2531Handler extends ZigBeeCoordinatorHandler {
private final Logger logger = LoggerFactory.getLogger(CC2531Handler.class);

public CC2531Handler(Bridge coordinator) {
super(coordinator);
public CC2531Handler(Bridge coordinator, ZigBeeChannelConverterFactory channelFactory) {
super(coordinator, channelFactory);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.openhab.binding.zigbee.cc2531.CC2531BindingConstants;
import org.openhab.binding.zigbee.cc2531.handler.CC2531Handler;
import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory;
import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* The {@link CC2531HandlerFactory} is responsible for creating things and thing
Expand All @@ -47,6 +49,18 @@ public class CC2531HandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
.singleton(CC2531BindingConstants.THING_TYPE_CC2531);

@Nullable
private ZigBeeChannelConverterFactory zigbeeChannelConverterFactory;

@Reference
protected void setZigBeeChannelConverterFactory(ZigBeeChannelConverterFactory zigbeeChannelConverterFactory) {
this.zigbeeChannelConverterFactory = zigbeeChannelConverterFactory;
}

protected void unsetZigBeeChannelConverterFactory(ZigBeeChannelConverterFactory zigbeeChannelConverterFactory) {
this.zigbeeChannelConverterFactory = null;
}

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
Expand All @@ -58,7 +72,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {

ZigBeeCoordinatorHandler coordinator = null;
if (thingTypeUID.equals(CC2531BindingConstants.THING_TYPE_CC2531)) {
coordinator = new CC2531Handler((Bridge) thing);
coordinator = new CC2531Handler((Bridge) thing, zigbeeChannelConverterFactory);
}

if (coordinator != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.smarthome.core.thing.binding.firmware.ProgressCallback;
import org.eclipse.smarthome.core.thing.binding.firmware.ProgressStep;
import org.openhab.binding.zigbee.ZigBeeBindingConstants;
import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory;
import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler;
import org.openhab.binding.zigbee.handler.ZigBeeSerialPort;
import org.openhab.binding.zigbee.telegesis.internal.TelegesisConfiguration;
Expand Down Expand Up @@ -52,8 +53,8 @@
public class TelegesisHandler extends ZigBeeCoordinatorHandler implements FirmwareUpdateHandler {
private final Logger logger = LoggerFactory.getLogger(TelegesisHandler.class);

public TelegesisHandler(Bridge coordinator) {
super(coordinator);
public TelegesisHandler(Bridge coordinator, ZigBeeChannelConverterFactory channelFactory) {
super(coordinator, channelFactory);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory;
import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory;
import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler;
import org.openhab.binding.zigbee.telegesis.TelegesisBindingConstants;
import org.openhab.binding.zigbee.telegesis.handler.TelegesisHandler;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* The {@link TelegesisHandlerFactory} is responsible for creating things and thing
Expand All @@ -47,6 +49,18 @@ public class TelegesisHandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
.singleton(TelegesisBindingConstants.THING_TYPE_TELEGESIS);

@Nullable
private ZigBeeChannelConverterFactory zigbeeChannelConverterFactory;

@Reference
protected void setZigBeeChannelConverterFactory(ZigBeeChannelConverterFactory zigbeeChannelConverterFactory) {
this.zigbeeChannelConverterFactory = zigbeeChannelConverterFactory;
}

protected void unsetZigBeeChannelConverterFactory(ZigBeeChannelConverterFactory zigbeeChannelConverterFactory) {
this.zigbeeChannelConverterFactory = null;
}

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
Expand All @@ -58,7 +72,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {

ZigBeeCoordinatorHandler coordinator = null;
if (thingTypeUID.equals(TelegesisBindingConstants.THING_TYPE_TELEGESIS)) {
coordinator = new TelegesisHandler((Bridge) thing);
coordinator = new TelegesisHandler((Bridge) thing, zigbeeChannelConverterFactory);
}

if (coordinator != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.eclipse.smarthome.core.thing.Bridge;
import org.openhab.binding.zigbee.ZigBeeBindingConstants;
import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory;
import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler;
import org.openhab.binding.zigbee.handler.ZigBeeSerialPort;
import org.openhab.binding.zigbee.xbee.internal.XBeeConfiguration;
Expand All @@ -38,8 +39,8 @@
public class XBeeHandler extends ZigBeeCoordinatorHandler {
private final Logger logger = LoggerFactory.getLogger(XBeeHandler.class);

public XBeeHandler(Bridge coordinator) {
super(coordinator);
public XBeeHandler(Bridge coordinator, ZigBeeChannelConverterFactory channelFactory) {
super(coordinator, channelFactory);
}

@Override
Expand All @@ -53,11 +54,11 @@ public void initialize() {

FlowControl flowControl;
if (ZigBeeBindingConstants.FLOWCONTROL_CONFIG_HARDWARE_CTSRTS.equals(config.zigbee_flowcontrol)) {
flowControl = FlowControl.FLOWCONTROL_OUT_RTSCTS;
flowControl = FlowControl.FLOWCONTROL_OUT_RTSCTS;
} else if (ZigBeeBindingConstants.FLOWCONTROL_CONFIG_SOFTWARE_XONXOFF.equals(config.zigbee_flowcontrol)) {
flowControl = FlowControl.FLOWCONTROL_OUT_XONOFF;
flowControl = FlowControl.FLOWCONTROL_OUT_XONOFF;
} else {
flowControl = FlowControl.FLOWCONTROL_OUT_NONE;
flowControl = FlowControl.FLOWCONTROL_OUT_NONE;
}

ZigBeePort serialPort = new ZigBeeSerialPort(config.zigbee_port, config.zigbee_baud, flowControl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Map;
import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.thing.Bridge;
import org.eclipse.smarthome.core.thing.Thing;
Expand All @@ -27,11 +26,13 @@
import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory;
import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory;
import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler;
import org.openhab.binding.zigbee.xbee.XBeeBindingConstants;
import org.openhab.binding.zigbee.xbee.handler.XBeeHandler;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* The {@link XBeeHandlerFactory} is responsible for creating things and thing
Expand All @@ -40,13 +41,25 @@
* @author Chris Jackson - Initial contribution
*/
@Component(service = ThingHandlerFactory.class, configurationPid = "org.openhab.binding.zigbee.xbee")
@NonNullByDefault
// @NonNullByDefault
public class XBeeHandlerFactory extends BaseThingHandlerFactory {
private Map<ThingUID, ServiceRegistration> coordinatorHandlerRegs = new HashMap<>();

private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
.singleton(XBeeBindingConstants.THING_TYPE_XBEE);

@Nullable
private ZigBeeChannelConverterFactory zigbeeChannelConverterFactory;

@Reference
protected void setZigBeeChannelConverterFactory(ZigBeeChannelConverterFactory zigbeeChannelConverterFactory) {
this.zigbeeChannelConverterFactory = zigbeeChannelConverterFactory;
}

protected void unsetZigBeeChannelConverterFactory(ZigBeeChannelConverterFactory zigbeeChannelConverterFactory) {
this.zigbeeChannelConverterFactory = null;
}

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
Expand All @@ -58,7 +71,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {

ZigBeeCoordinatorHandler coordinator = null;
if (thingTypeUID.equals(XBeeBindingConstants.THING_TYPE_XBEE)) {
coordinator = new XBeeHandler((Bridge) thing);
coordinator = new XBeeHandler((Bridge) thing, zigbeeChannelConverterFactory);
}

if (coordinator != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
package org.openhab.binding.zigbee.internal.converter;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.measure.quantity.ElectricPotential;

Expand Down Expand Up @@ -45,6 +49,16 @@ public class ZigBeeConverterBatteryVoltage extends ZigBeeBaseChannelConverter im

private ZclPowerConfigurationCluster cluster;

@Override
public Set<Integer> getImplementedClientClusters() {
return Stream.of(ZclPowerConfigurationCluster.CLUSTER_ID).collect(Collectors.toSet());
}

@Override
public Set<Integer> getImplementedServerClusters() {
return Collections.emptySet();
}

@Override
public boolean initializeDevice() {
logger.debug("{}: Initialising device battery voltage converter", endpoint.getIeeeAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@

import static com.zsmartsystems.zigbee.zcl.clusters.ZclColorControlCluster.*;

import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.smarthome.config.core.Configuration;
Expand Down Expand Up @@ -89,6 +93,18 @@ public class ZigBeeConverterColorColor extends ZigBeeBaseChannelConverter implem

private ZclLevelControlConfig configLevelControl;

@Override
public Set<Integer> getImplementedClientClusters() {
return Stream
.of(ZclOnOffCluster.CLUSTER_ID, ZclLevelControlCluster.CLUSTER_ID, ZclColorControlCluster.CLUSTER_ID)
.collect(Collectors.toSet());
}

@Override
public Set<Integer> getImplementedServerClusters() {
return Collections.emptySet();
}

@Override
public boolean initializeDevice() {
ZclColorControlCluster serverClusterColorControl = (ZclColorControlCluster) endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

import static com.zsmartsystems.zigbee.zcl.clusters.ZclColorControlCluster.ATTR_COLORTEMPERATURE;

import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.library.types.PercentType;
Expand Down Expand Up @@ -58,6 +62,16 @@ public class ZigBeeConverterColorTemperature extends ZigBeeBaseChannelConverter
private final Integer DEFAULT_MIN_TEMPERATURE_IN_KELVIN = 2000;
private final Integer DEFAULT_MAX_TEMPERATURE_IN_KELVIN = 6500;

@Override
public Set<Integer> getImplementedClientClusters() {
return Stream.of(ZclColorControlCluster.CLUSTER_ID).collect(Collectors.toSet());
}

@Override
public Set<Integer> getImplementedServerClusters() {
return Collections.emptySet();
}

@Override
public boolean initializeDevice() {
ZclColorControlCluster serverClusterColorControl = (ZclColorControlCluster) endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
*/
package org.openhab.binding.zigbee.internal.converter;

import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.thing.Channel;
Expand Down Expand Up @@ -43,6 +47,16 @@ public class ZigBeeConverterDoorLock extends ZigBeeBaseChannelConverter implemen

private ZclDoorLockCluster cluster;

@Override
public Set<Integer> getImplementedClientClusters() {
return Stream.of(ZclDoorLockCluster.CLUSTER_ID).collect(Collectors.toSet());
}

@Override
public Set<Integer> getImplementedServerClusters() {
return Collections.emptySet();
}

@Override
public boolean initializeDevice() {
ZclDoorLockCluster serverCluster = (ZclDoorLockCluster) endpoint.getInputCluster(ZclDoorLockCluster.CLUSTER_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
*/
package org.openhab.binding.zigbee.internal.converter;

import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.eclipse.smarthome.core.library.types.DecimalType;
import org.eclipse.smarthome.core.library.types.OnOffType;
Expand Down Expand Up @@ -51,6 +55,16 @@ public class ZigBeeConverterFanControl extends ZigBeeBaseChannelConverter implem
private ZclFanControlCluster cluster;
private ZclAttribute fanModeAttribute;

@Override
public Set<Integer> getImplementedClientClusters() {
return Stream.of(ZclFanControlCluster.CLUSTER_ID).collect(Collectors.toSet());
}

@Override
public Set<Integer> getImplementedServerClusters() {
return Collections.emptySet();
}

@Override
public boolean initializeDevice() {
ZclFanControlCluster serverCluster = (ZclFanControlCluster) endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -70,6 +71,16 @@ public class ZigBeeConverterGenericButton extends ZigBeeBaseChannelConverter
private Set<ZclCluster> clientClusters = new HashSet<>();
private Set<ZclCluster> serverClusters = new HashSet<>();

@Override
public Set<Integer> getImplementedClientClusters() {
return Collections.emptySet();
}

@Override
public Set<Integer> getImplementedServerClusters() {
return Collections.emptySet();
}

@Override
public synchronized boolean initializeConverter() {
for (ButtonPressType buttonPressType : ButtonPressType.values()) {
Expand Down
Loading

0 comments on commit e5abeb8

Please sign in to comment.