Skip to content

Commit

Permalink
Remove deprecations from battery voltage converter (#814)
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 Nov 19, 2023
1 parent 25fcdfa commit 30e60c5
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -47,6 +47,7 @@ public class ZigBeeConverterBatteryVoltage extends ZigBeeBaseChannelConverter im
private Logger logger = LoggerFactory.getLogger(ZigBeeConverterBatteryVoltage.class);

private ZclPowerConfigurationCluster cluster;
private ZclAttribute attribute;

@Override
public Set<Integer> getImplementedClientClusters() {
Expand Down Expand Up @@ -74,8 +75,7 @@ public boolean initializeDevice() {
if (bindResponse.isSuccess()) {
ZclAttribute attribute = serverCluster.getAttribute(ZclPowerConfigurationCluster.ATTR_BATTERYVOLTAGE);
// Configure reporting - no faster than once per ten minutes - no slower than every 2 hours.
CommandResult reportingResponse = serverCluster
.setReporting(attribute, 600, REPORTING_PERIOD_DEFAULT_MAX, 1).get();
CommandResult reportingResponse = attribute.setReporting(600, REPORTING_PERIOD_DEFAULT_MAX, 1).get();
handleReportingResponse(reportingResponse, POLLING_PERIOD_HIGH, REPORTING_PERIOD_DEFAULT_MAX);
}
} catch (InterruptedException | ExecutionException e) {
Expand All @@ -94,6 +94,8 @@ public boolean initializeConverter(ZigBeeThingHandler thing) {
return false;
}

attribute = cluster.getAttribute(ZclPowerConfigurationCluster.ATTR_BATTERYVOLTAGE);

// Add a listener, then request the status
cluster.addAttributeListener(this);
return true;
Expand All @@ -108,7 +110,7 @@ public void disposeConverter() {

@Override
public void handleRefresh() {
cluster.getBatteryVoltage(0);
attribute.readValue(0);
}

@Override
Expand All @@ -120,7 +122,8 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) {
return null;
}

if (powerCluster.getBatteryVoltage(Long.MAX_VALUE) == null) {
ZclAttribute attribute = cluster.getAttribute(ZclPowerConfigurationCluster.ATTR_BATTERYVOLTAGE);
if (attribute.readValue(Long.MAX_VALUE) == null) {
logger.trace("{}: Power configuration cluster battery voltage returned null", endpoint.getIeeeAddress());
return null;
}
Expand Down

1 comment on commit 30e60c5

@openhab-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/openhab-4-1-milestone-discussion/149502/110

Please sign in to comment.