Skip to content

Commit

Permalink
Change Level converter to only use Level cluster (#84)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <chris@cd-jackson.com>
  • Loading branch information
cdjackson committed Jan 9, 2018
1 parent d53d16e commit 25dfb38
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 44 deletions.
Binary file not shown.
Binary file modified lib/com.zsmartsystems.zigbee.dongle.telegesis-1.0.3-SNAPSHOT.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.zsmartsystems.zigbee.zcl.ZclAttribute;
import com.zsmartsystems.zigbee.zcl.ZclAttributeListener;
import com.zsmartsystems.zigbee.zcl.clusters.ZclLevelControlCluster;
import com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster;
import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType;

/**
Expand All @@ -37,7 +36,6 @@
public class ZigBeeConverterSwitchLevel extends ZigBeeBaseChannelConverter implements ZclAttributeListener {
private Logger logger = LoggerFactory.getLogger(ZigBeeConverterSwitchLevel.class);

private ZclOnOffCluster clusterOnOff;
private ZclLevelControlCluster clusterLevelControl;
private ZclLevelControlConfig configLevelControl;

Expand All @@ -48,10 +46,6 @@ public boolean initializeConverter() {
logger.error("{}: Error opening device level controls", endpoint.getIeeeAddress());
return false;
}
clusterOnOff = (ZclOnOffCluster) endpoint.getInputCluster(ZclOnOffCluster.CLUSTER_ID);
if (clusterLevelControl == null) {
logger.debug("{}: Error opening device onoff controls - will use level cluster", endpoint.getIeeeAddress());
}

try {
CommandResult bindResponse = clusterLevelControl.bind().get();
Expand All @@ -72,27 +66,6 @@ public boolean initializeConverter() {
clusterLevelControl.addAttributeListener(this);
clusterLevelControl.getCurrentLevel(0);

if (clusterOnOff != null) {
try {
CommandResult bindResponse = clusterOnOff.bind().get();
if (bindResponse.isSuccess()) {
// Configure reporting - no faster than once per second - no slower than 10 minutes.
CommandResult reportingResponse = clusterOnOff.setOnOffReporting(1, 600).get();
if (reportingResponse.isError()) {
pollingPeriod = POLLING_PERIOD_HIGH;
}
} else {
pollingPeriod = POLLING_PERIOD_HIGH;
}
} catch (InterruptedException | ExecutionException e) {
logger.error("{}: Exception setting reporting ", endpoint.getIeeeAddress(), e);
}

// Add a listener, then request the status
clusterOnOff.addAttributeListener(this);
clusterOnOff.getOnOff(0);
}

// Create a configuration handler and get the available options
configLevelControl = new ZclLevelControlConfig(clusterLevelControl);
configOptions = configLevelControl.getConfiguration();
Expand All @@ -117,15 +90,6 @@ public void handleCommand(final Command command) {
level = ((PercentType) command).intValue();
} else if (command instanceof OnOffType) {
OnOffType cmdOnOff = (OnOffType) command;
if (clusterOnOff != null) {
if (cmdOnOff == OnOffType.ON) {
clusterOnOff.onCommand();
} else {
clusterOnOff.offCommand();
}
return;
}

if (cmdOnOff == OnOffType.ON) {
level = 100;
} else {
Expand Down Expand Up @@ -165,13 +129,5 @@ public void attributeUpdated(ZclAttribute attribute) {
}
return;
}
if (attribute.getCluster() == ZclClusterType.ON_OFF && attribute.getId() == ZclOnOffCluster.ATTR_ONOFF) {
Boolean value = (Boolean) attribute.getLastValue();
if (value != null && value == true) {
updateChannelState(OnOffType.ON);
} else {
updateChannelState(OnOffType.OFF);
}
}
}
}

0 comments on commit 25dfb38

Please sign in to comment.