]> git.basschouten.com Git - openhab-addons.git/commitdiff
[homematic] Provide additional null pointer checks (#10965)
authorMartin Herbst <develop@mherbst.de>
Thu, 15 Jul 2021 17:46:29 +0000 (19:46 +0200)
committerGitHub <noreply@github.com>
Thu, 15 Jul 2021 17:46:29 +0000 (19:46 +0200)
* Fixed a rare NPE introduced while replacing commons-lang
* Provide additional null pointer checks

It is possible that the meta data returned for some device does not
contain a default or maximum value.

Fixes #10945
Fixes #10961

Signed-off-by: Martin Herbst <develop@mherbst.de>
bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/type/HomematicTypeGeneratorImpl.java

index 147c65c347eade0e84bfb28069715933c2a9c159..6577cb77f1e8d12deefb2967f0cddfac4963ccab 100644 (file)
@@ -169,8 +169,8 @@ public class HomematicTypeGeneratorImpl implements HomematicTypeGenerator {
                     ChannelGroupTypeUID groupTypeUID = UidUtils.generateChannelGroupTypeUID(channel);
                     ChannelGroupType groupType = channelGroupTypeProvider.getInternalChannelGroupType(groupTypeUID);
                     if (groupType == null || device.isGatewayExtras()) {
-                        String groupLabel = String.format("%s",
-                                MiscUtils.capitalize(channel.getType().replace("_", " ")));
+                        String groupLabel = String.format("%s", channel.getType() == null ? null
+                                MiscUtils.capitalize(channel.getType().replace("_", " ")));
                         groupType = ChannelGroupTypeBuilder.instance(groupTypeUID, groupLabel)
                                 .withChannelDefinitions(channelDefinitions).build();
                         channelGroupTypeProvider.addChannelGroupType(groupType);
@@ -355,7 +355,8 @@ public class HomematicTypeGeneratorImpl implements HomematicTypeGenerator {
                         Number defaultValue = (Number) dp.getDefaultValue();
                         Number maxValue = dp.getMaxValue();
                         // some datapoints can have a default value that is greater than the maximum value
-                        if (defaultValue.doubleValue() > maxValue.doubleValue()) {
+                        if (defaultValue != null && maxValue != null
+                                && defaultValue.doubleValue() > maxValue.doubleValue()) {
                             maxValue = defaultValue;
                         }
                         builder.withMinimum(MetadataUtils.createBigDecimal(dp.getMinValue()));