[mercedesme] Add vin automatically to discovered vehicle (#17750)

* add vin as representation property

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Bernd Weymann 2024-11-16 13:04:31 +01:00 committed by Ciprian Pascu
parent f9dee9230e
commit 22f953ff00
2 changed files with 6 additions and 2 deletions

View File

@ -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());
}
}

View File

@ -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<String, Object> discoveryProperties = getCapabilities(vin);
discoveryProperties.put("vin", vin);
discoveryService.vehicleDiscovered(this, vin, discoveryProperties);
}
}
}