Skip to content

Commit

Permalink
Simplify battery voltage converter support detection (openhab#749)
Browse files Browse the repository at this point in the history
Simplify battery voltage converter support detection (similar to Chris change for battery percent converter)

Signed-off-by: FranzSchi <Franz.Schindler@web.de>
  • Loading branch information
FranzSchi authored and Pierre Gaufillet committed Sep 7, 2023
1 parent 5705ca2 commit 62ef79e
Showing 1 changed file with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,8 @@ public Channel getChannel(ThingUID thingUID, ZigBeeEndpoint endpoint) {
return null;
}

try {
if (!powerCluster.discoverAttributes(false).get()
&& !powerCluster.isAttributeSupported(ZclPowerConfigurationCluster.ATTR_BATTERYVOLTAGE)) {
logger.trace("{}: Power configuration cluster battery voltage not supported",
endpoint.getIeeeAddress());

return null;
} else if (powerCluster.getBatteryVoltage(Long.MAX_VALUE) == null) {
logger.trace("{}: Power configuration cluster battery voltage returned null",
endpoint.getIeeeAddress());
return null;
}
} catch (InterruptedException | ExecutionException e) {
logger.warn("{}: Exception discovering attributes in power configuration cluster",
endpoint.getIeeeAddress(), e);
if (powerCluster.getBatteryVoltage(Long.MAX_VALUE) == null) {
logger.trace("{}: Power configuration cluster battery voltage returned null", endpoint.getIeeeAddress());
return null;
}

Expand Down

0 comments on commit 62ef79e

Please sign in to comment.