[miio] Check for null properties (#9408)

Signed-off-by: Mark Hilbush <mark@hilbush.com>
This commit is contained in:
Mark Hilbush 2020-12-17 20:41:28 -05:00 committed by GitHub
parent a7009101ba
commit 74bdcb6e85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -95,12 +95,17 @@ public class MiIoDiscovery extends AbstractDiscoveryService {
if (miioConfig != null) { if (miioConfig != null) {
try { try {
Dictionary<String, @Nullable Object> properties = miioConfig.getProperties(); Dictionary<String, @Nullable Object> properties = miioConfig.getProperties();
String cloudDiscoveryModeConfig = (String) properties.get("cloudDiscoveryMode"); String cloudDiscoveryModeConfig;
if (properties == null) {
cloudDiscoveryModeConfig = DISABLED;
} else {
cloudDiscoveryModeConfig = (String) properties.get("cloudDiscoveryMode");
if (cloudDiscoveryModeConfig == null) { if (cloudDiscoveryModeConfig == null) {
cloudDiscoveryModeConfig = DISABLED; cloudDiscoveryModeConfig = DISABLED;
} else { } else {
cloudDiscoveryModeConfig = cloudDiscoveryModeConfig.toLowerCase(); cloudDiscoveryModeConfig = cloudDiscoveryModeConfig.toLowerCase();
} }
}
return Set.of(SUPPORTED, ALL).contains(cloudDiscoveryModeConfig) ? cloudDiscoveryModeConfig : DISABLED; return Set.of(SUPPORTED, ALL).contains(cloudDiscoveryModeConfig) ? cloudDiscoveryModeConfig : DISABLED;
} catch (ClassCastException | SecurityException e) { } catch (ClassCastException | SecurityException e) {
logger.debug("Error getting cloud discovery configuration: {}", e.getMessage()); logger.debug("Error getting cloud discovery configuration: {}", e.getMessage());