[homekit] fix potential null pointer exceptions (#13122)
* fix potential null pointer exceptions * use contains key Signed-off-by: Eugen Freiter <freiter@gmx.de>
This commit is contained in:
parent
7a53e313cd
commit
94615b7728
@ -148,6 +148,8 @@ public class HomekitImpl implements Homekit, NetworkAddressChangeListener {
|
|||||||
try {
|
try {
|
||||||
HomekitSettings oldSettings = settings;
|
HomekitSettings oldSettings = settings;
|
||||||
settings = processConfig(config);
|
settings = processConfig(config);
|
||||||
|
if ((oldSettings == null) || (settings == null))
|
||||||
|
return;
|
||||||
changeListener.updateSettings(settings);
|
changeListener.updateSettings(settings);
|
||||||
if (!oldSettings.networkInterface.equals(settings.networkInterface) || oldSettings.port != settings.port
|
if (!oldSettings.networkInterface.equals(settings.networkInterface) || oldSettings.port != settings.port
|
||||||
|| oldSettings.useOHmDNS != settings.useOHmDNS) {
|
|| oldSettings.useOHmDNS != settings.useOHmDNS) {
|
||||||
|
|||||||
@ -142,17 +142,18 @@ public class HomekitAccessoryFactory {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static List<HomekitCharacteristicType> getRequiredCharacteristics(HomekitTaggedItem taggedItem) {
|
private static List<HomekitCharacteristicType> getRequiredCharacteristics(HomekitTaggedItem taggedItem) {
|
||||||
|
final List<HomekitCharacteristicType> characteristics = new ArrayList<>();
|
||||||
|
if (MANDATORY_CHARACTERISTICS.containsKey(taggedItem.getAccessoryType())) {
|
||||||
|
characteristics.addAll(Arrays.asList(MANDATORY_CHARACTERISTICS.get(taggedItem.getAccessoryType())));
|
||||||
|
}
|
||||||
if (taggedItem.getAccessoryType() == BATTERY) {
|
if (taggedItem.getAccessoryType() == BATTERY) {
|
||||||
final String isChargeable = taggedItem.getConfiguration(HomekitBatteryImpl.BATTERY_TYPE, "false");
|
final String isChargeable = taggedItem.getConfiguration(HomekitBatteryImpl.BATTERY_TYPE, "false");
|
||||||
if ("true".equalsIgnoreCase(isChargeable) || "yes".equalsIgnoreCase(isChargeable)) {
|
if ("true".equalsIgnoreCase(isChargeable) || "yes".equalsIgnoreCase(isChargeable)) {
|
||||||
final List<HomekitCharacteristicType> characteristics = new ArrayList<>();
|
|
||||||
characteristics.addAll(Arrays.asList(MANDATORY_CHARACTERISTICS.get(taggedItem.getAccessoryType())));
|
|
||||||
characteristics.add(BATTERY_CHARGING_STATE);
|
characteristics.add(BATTERY_CHARGING_STATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
return characteristics;
|
return characteristics;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return Arrays.asList(MANDATORY_CHARACTERISTICS.get(taggedItem.getAccessoryType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates HomeKit accessory for an openhab item.
|
* creates HomeKit accessory for an openhab item.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user