Skip to content

Commit

Permalink
[homematic] Provide additional null pointer checks (openhab#10965)
Browse files Browse the repository at this point in the history
* 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 openhab#10945
Fixes openhab#10961

Signed-off-by: Martin Herbst <develop@mherbst.de>
  • Loading branch information
MHerbst authored and thinkingstone committed Nov 7, 2021
1 parent bc0c581 commit d76ced6
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public void generate(HmDevice device) {
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);
Expand Down Expand Up @@ -355,7 +355,8 @@ public ParameterOption createOption(String value, String description) {
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()));
Expand Down

0 comments on commit d76ced6

Please sign in to comment.