[homematic] Provide additional null pointer checks (#10965)
* 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>
This commit is contained in:
parent
03d9281c0b
commit
b043d8f4bc
|
@ -169,8 +169,8 @@ public class HomematicTypeGeneratorImpl implements HomematicTypeGenerator {
|
||||||
ChannelGroupTypeUID groupTypeUID = UidUtils.generateChannelGroupTypeUID(channel);
|
ChannelGroupTypeUID groupTypeUID = UidUtils.generateChannelGroupTypeUID(channel);
|
||||||
ChannelGroupType groupType = channelGroupTypeProvider.getInternalChannelGroupType(groupTypeUID);
|
ChannelGroupType groupType = channelGroupTypeProvider.getInternalChannelGroupType(groupTypeUID);
|
||||||
if (groupType == null || device.isGatewayExtras()) {
|
if (groupType == null || device.isGatewayExtras()) {
|
||||||
String groupLabel = String.format("%s",
|
String groupLabel = String.format("%s", channel.getType() == null ? null
|
||||||
MiscUtils.capitalize(channel.getType().replace("_", " ")));
|
: MiscUtils.capitalize(channel.getType().replace("_", " ")));
|
||||||
groupType = ChannelGroupTypeBuilder.instance(groupTypeUID, groupLabel)
|
groupType = ChannelGroupTypeBuilder.instance(groupTypeUID, groupLabel)
|
||||||
.withChannelDefinitions(channelDefinitions).build();
|
.withChannelDefinitions(channelDefinitions).build();
|
||||||
channelGroupTypeProvider.addChannelGroupType(groupType);
|
channelGroupTypeProvider.addChannelGroupType(groupType);
|
||||||
|
@ -355,7 +355,8 @@ public class HomematicTypeGeneratorImpl implements HomematicTypeGenerator {
|
||||||
Number defaultValue = (Number) dp.getDefaultValue();
|
Number defaultValue = (Number) dp.getDefaultValue();
|
||||||
Number maxValue = dp.getMaxValue();
|
Number maxValue = dp.getMaxValue();
|
||||||
// some datapoints can have a default value that is greater than the maximum value
|
// 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;
|
maxValue = defaultValue;
|
||||||
}
|
}
|
||||||
builder.withMinimum(MetadataUtils.createBigDecimal(dp.getMinValue()));
|
builder.withMinimum(MetadataUtils.createBigDecimal(dp.getMinValue()));
|
||||||
|
|
Loading…
Reference in New Issue