Skip to content

Commit

Permalink
Update Binary Input converter
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <[email protected]>
  • Loading branch information
cdjackson committed Dec 25, 2019
1 parent b5b1ee1 commit 07e942e
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
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.Pressure;

Expand Down Expand Up @@ -56,7 +54,7 @@ public class ZigBeeConverterAtmosphericPressure extends ZigBeeBaseChannelConvert

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
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.StringType;
import org.eclipse.smarthome.core.thing.Channel;
Expand Down Expand Up @@ -74,7 +72,7 @@ public class ZigBeeConverterBatteryAlarm extends ZigBeeBaseChannelConverter impl

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
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.thing.Channel;
Expand Down Expand Up @@ -49,7 +47,7 @@ public class ZigBeeConverterBatteryPercent extends ZigBeeBaseChannelConverter im

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
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 @@ -51,7 +49,7 @@ public class ZigBeeConverterBatteryVoltage extends ZigBeeBaseChannelConverter im

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
*/
package org.openhab.binding.zigbee.internal.converter;

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.clusters.ZclBinaryInputBasicCluster;
import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ExecutionException;

import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.thing.Channel;
import org.eclipse.smarthome.core.thing.ThingUID;
Expand All @@ -27,7 +25,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.ExecutionException;
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.clusters.ZclBinaryInputBasicCluster;
import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType;

/**
* Converter for the binary input sensor.
Expand All @@ -40,6 +43,16 @@ public class ZigBeeConverterBinaryInput extends ZigBeeBaseChannelConverter imple

private ZclBinaryInputBasicCluster binaryInputCluster;

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

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

@Override
public boolean initializeDevice() {
logger.debug("{}: Initialising device binary input cluster", endpoint.getIeeeAddress());
Expand Down Expand Up @@ -68,7 +81,8 @@ public boolean initializeDevice() {

@Override
public boolean initializeConverter() {
binaryInputCluster = (ZclBinaryInputBasicCluster) endpoint.getInputCluster(ZclBinaryInputBasicCluster.CLUSTER_ID);
binaryInputCluster = (ZclBinaryInputBasicCluster) endpoint
.getInputCluster(ZclBinaryInputBasicCluster.CLUSTER_ID);
if (binaryInputCluster == null) {
logger.error("{}: Error opening binary input cluster", endpoint.getIeeeAddress());
return false;
Expand Down Expand Up @@ -101,8 +115,8 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) {
.create(createChannelUID(thingUID, endpoint, ZigBeeBindingConstants.CHANNEL_NAME_BINARYINPUT),
ZigBeeBindingConstants.ITEM_TYPE_SWITCH)
.withType(ZigBeeBindingConstants.CHANNEL_BINARYINPUT)
.withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_BINARYINPUT)
.withProperties(createProperties(endpoint)).build();
.withLabel(ZigBeeBindingConstants.CHANNEL_LABEL_BINARYINPUT).withProperties(createProperties(endpoint))
.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
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 @@ -64,7 +62,7 @@ public class ZigBeeConverterColorTemperature extends ZigBeeBaseChannelConverter

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
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 @@ -49,7 +47,7 @@ public class ZigBeeConverterDoorLock extends ZigBeeBaseChannelConverter implemen

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
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 @@ -57,7 +55,7 @@ public class ZigBeeConverterFanControl extends ZigBeeBaseChannelConverter implem

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
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 @@ -60,7 +58,7 @@ public class ZigBeeConverterIlluminance extends ZigBeeBaseChannelConverter imple

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
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.Power;

Expand Down Expand Up @@ -53,7 +51,7 @@ public class ZigBeeConverterMeasurementPower extends ZigBeeBaseChannelConverter

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
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.ElectricCurrent;

Expand Down Expand Up @@ -54,7 +52,7 @@ public class ZigBeeConverterMeasurementRmsCurrent extends ZigBeeBaseChannelConve

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
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 @@ -54,7 +52,7 @@ public class ZigBeeConverterMeasurementRmsVoltage extends ZigBeeBaseChannelConve

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
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 @@ -47,7 +45,7 @@ public class ZigBeeConverterOccupancy extends ZigBeeBaseChannelConverter impleme

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
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.thing.Channel;
Expand Down Expand Up @@ -48,7 +46,7 @@ public class ZigBeeConverterRelativeHumidity extends ZigBeeBaseChannelConverter

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.openhab.binding.zigbee.internal.converter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
Expand All @@ -21,8 +22,6 @@
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 @@ -81,12 +80,12 @@ public class ZigBeeConverterSwitchOnoff extends ZigBeeBaseChannelConverter

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

@Override
public Set<Integer> getImplementedServerClusters() {
return Stream.of(ZclOnOffCluster.CLUSTER_ID).collect(Collectors.toSet());
return Collections.singleton(ZclOnOffCluster.CLUSTER_ID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
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.thing.Channel;
import org.eclipse.smarthome.core.thing.ThingUID;
Expand Down Expand Up @@ -46,7 +44,7 @@ public class ZigBeeConverterTemperature extends ZigBeeBaseChannelConverter imple

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
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.thing.Channel;
import org.eclipse.smarthome.core.thing.ThingUID;
Expand Down Expand Up @@ -49,7 +47,7 @@ public class ZigBeeConverterThermostatLocalTemperature extends ZigBeeBaseChannel

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
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.thing.Channel;
import org.eclipse.smarthome.core.thing.ThingUID;
Expand Down Expand Up @@ -51,7 +49,7 @@ public class ZigBeeConverterThermostatOccupiedCooling extends ZigBeeBaseChannelC

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

@Override
Expand Down
Loading

0 comments on commit 07e942e

Please sign in to comment.