From 22f953ff008a72ead635e2ed7bdf645964294b7e Mon Sep 17 00:00:00 2001 From: Bernd Weymann Date: Sat, 16 Nov 2024 13:04:31 +0100 Subject: [PATCH] [mercedesme] Add vin automatically to discovered vehicle (#17750) * add vin as representation property Signed-off-by: Bernd Weymann Signed-off-by: Ciprian Pascu --- .../internal/discovery/MercedesMeDiscoveryService.java | 4 +++- .../binding/mercedesme/internal/handler/AccountHandler.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/discovery/MercedesMeDiscoveryService.java b/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/discovery/MercedesMeDiscoveryService.java index 3042c500133..cf2dafb8232 100644 --- a/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/discovery/MercedesMeDiscoveryService.java +++ b/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/discovery/MercedesMeDiscoveryService.java @@ -29,6 +29,7 @@ import org.osgi.service.component.annotations.Component; * associated vehicles and provides DiscoveryResults * * @author Bernd Weymann - Initial Contribution + * @author Bernd Weymann - Add vin as representation property */ @NonNullByDefault @Component(service = DiscoveryService.class, configurationPid = "discovery.mercedesme") @@ -56,8 +57,9 @@ public class MercedesMeDiscoveryService extends AbstractDiscoveryService { break; } if (ttuid != null) { + properties.put("vin", vin); thingDiscovered(DiscoveryResultBuilder.create(new ThingUID(ttuid, ac.getThing().getUID(), vin)) - .withBridge(ac.getThing().getUID()).withProperties(properties) + .withBridge(ac.getThing().getUID()).withProperties(properties).withRepresentationProperty("vin") .withLabel("Mercedes Benz " + ttuid.getId().toUpperCase()).build()); } } diff --git a/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/handler/AccountHandler.java b/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/handler/AccountHandler.java index 13e1d18710d..ded788084a3 100644 --- a/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/handler/AccountHandler.java +++ b/bundles/org.openhab.binding.mercedesme/src/main/java/org/openhab/binding/mercedesme/internal/handler/AccountHandler.java @@ -324,7 +324,9 @@ public class AccountHandler extends BaseBridgeHandler implements AccessTokenRefr } else { if (!capabilitiesMap.containsKey(vin)) { // only report new discovery if capabilities aren't discovered yet - discoveryService.vehicleDiscovered(this, vin, getCapabilities(vin)); + Map discoveryProperties = getCapabilities(vin); + discoveryProperties.put("vin", vin); + discoveryService.vehicleDiscovered(this, vin, discoveryProperties); } } }