mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
bugfix discovery and thing properties (#18003)
Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
This commit is contained in:
parent
33d3577230
commit
1b02f98b46
@ -271,6 +271,7 @@ public class AccountHandler extends BaseBridgeHandler implements AccessTokenRefr
|
||||
public void registerVin(String vin, VehicleHandler handler) {
|
||||
discoveryService.vehicleRemove(this, vin, handler.getThing().getThingTypeUID().getId());
|
||||
activeVehicleHandlerMap.put(vin, handler);
|
||||
discovery(vin); // update properties for added vehicle
|
||||
VEPUpdate updateForVin = vepUpdateMap.get(vin);
|
||||
if (updateForVin != null) {
|
||||
handler.enqueueUpdate(updateForVin);
|
||||
@ -340,7 +341,6 @@ public class AccountHandler extends BaseBridgeHandler implements AccessTokenRefr
|
||||
PushMessage pm = VehicleEvents.PushMessage.parseFrom(array);
|
||||
if (pm.hasVepUpdates()) {
|
||||
boolean distributed = distributeVepUpdates(pm.getVepUpdates().getUpdatesMap());
|
||||
logger.trace("Distributed VEPUpdate {}", distributed);
|
||||
if (distributed) {
|
||||
AcknowledgeVEPUpdatesByVIN ack = AcknowledgeVEPUpdatesByVIN.newBuilder()
|
||||
.setSequenceNumber(pm.getVepUpdates().getSequenceNumber()).build();
|
||||
@ -349,7 +349,7 @@ public class AccountHandler extends BaseBridgeHandler implements AccessTokenRefr
|
||||
}
|
||||
} else if (pm.hasAssignedVehicles()) {
|
||||
for (int i = 0; i < pm.getAssignedVehicles().getVinsCount(); i++) {
|
||||
String vin = pm.getAssignedVehicles().getVins(0);
|
||||
String vin = pm.getAssignedVehicles().getVins(i);
|
||||
discovery(vin);
|
||||
}
|
||||
AcknowledgeAssignedVehicles ack = AcknowledgeAssignedVehicles.newBuilder().build();
|
||||
@ -394,6 +394,7 @@ public class AccountHandler extends BaseBridgeHandler implements AccessTokenRefr
|
||||
}
|
||||
});
|
||||
notFoundList.forEach(vin -> {
|
||||
discovery(vin); // add vehicle to discovery
|
||||
logger.trace("No VehicleHandler available for VIN {}", vin);
|
||||
});
|
||||
return notFoundList.isEmpty();
|
||||
@ -410,13 +411,18 @@ public class AccountHandler extends BaseBridgeHandler implements AccessTokenRefr
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates properties for existing handlers or delivers discovery result
|
||||
*
|
||||
* @param vin of discovered vehicle
|
||||
*/
|
||||
@SuppressWarnings("null")
|
||||
public void discovery(String vin) {
|
||||
if (activeVehicleHandlerMap.containsKey(vin)) {
|
||||
VehicleHandler vh = activeVehicleHandlerMap.get(vin);
|
||||
if (vh.getThing().getProperties().isEmpty()) {
|
||||
vh.getThing().setProperties(getStringCapabilities(vin));
|
||||
}
|
||||
Map<String, String> properties = getStringCapabilities(vin);
|
||||
properties.putAll(vh.getThing().getProperties());
|
||||
vh.getThing().setProperties(properties);
|
||||
} else {
|
||||
if (!capabilitiesMap.containsKey(vin)) {
|
||||
// only report new discovery if capabilities aren't discovered yet
|
||||
|
Loading…
Reference in New Issue
Block a user