[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

View File

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