[amazonechocontrol] fix smarthome device naming (#10084)

* fix smarthome device naming
* toString

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
J-N-K 2021-02-07 22:56:31 +01:00 committed by GitHub
parent 7269cbfbf5
commit b65e932650
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 7 deletions

View File

@ -14,14 +14,10 @@ package org.openhab.binding.amazonechocontrol.internal.discovery;
import static org.openhab.binding.amazonechocontrol.internal.AmazonEchoControlBindingConstants.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
@ -180,7 +176,17 @@ public class SmartHomeDevicesDiscovery extends AbstractDiscoveryService {
List<JsonSmartHomeDeviceAlias> aliases = shd.aliases;
if ("Amazon".equals(shd.manufacturerName) && driverIdentity != null
&& "SonarCloudService".equals(driverIdentity.identifier)) {
deviceName = "Alexa Guard on " + shd.friendlyName;
List<@Nullable String> interfaces = shd.getCapabilities().stream().map(c -> c.interfaceName)
.collect(Collectors.toList());
if (interfaces.contains("Alexa.AcousticEventSensor")) {
deviceName = "Alexa Guard on " + shd.friendlyName;
} else if (interfaces.contains("Alexa.ColorController")) {
deviceName = "Alexa Color Controller on " + shd.friendlyName;
} else if (interfaces.contains("Alexa.PowerController")) {
deviceName = "Alexa Plug on " + shd.friendlyName;
} else {
deviceName = "Unknown Device on " + shd.friendlyName;
}
} else if ("Amazon".equals(shd.manufacturerName) && driverIdentity != null
&& "OnGuardSmartHomeBridgeService".equals(driverIdentity.identifier)) {
deviceName = "Alexa Guard";

View File

@ -29,15 +29,32 @@ public class JsonSmartHomeCapabilities {
public @Nullable String version;
public @Nullable String interfaceName;
public @Nullable Properties properties;
@Override
public String toString() {
return "SmartHomeCapability{" + "capabilityType='" + capabilityType + '\'' + ", type='" + type + '\''
+ ", version='" + version + '\'' + ", interfaceName='" + interfaceName + '\'' + ", properties="
+ properties + '}';
}
}
public static class Properties {
public @Nullable List<Property> supported;
@Override
public String toString() {
return "Properties{" + "supported=" + supported + '}';
}
}
public static class Property {
public @Nullable String name;
}
@Override
public String toString() {
return "JsonSmartHomeCapabilities{" + "capabilites=" + capabilites + '}';
}
public @Nullable List<SmartHomeCapability> capabilites;
}