mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[evcc] Fix IllegalArgumentException
for specific vehicle Id's (#17380)
* Handle semicolon in car id Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
parent
110fd9b1ca
commit
16a6853efb
@ -75,6 +75,7 @@ public class EvccAPI {
|
||||
*/
|
||||
public Result getResult() throws EvccApiException {
|
||||
final String response = httpRequest(this.host + EVCC_REST_API + "state", "GET");
|
||||
logger.trace("API Response >> {}", response);
|
||||
try {
|
||||
Status status = gson.fromJson(response, Status.class);
|
||||
if (status == null) {
|
||||
|
@ -271,7 +271,7 @@ public class Loadpoint {
|
||||
* @return vehicle's title/name
|
||||
*/
|
||||
public String getVehicleName() {
|
||||
return vehicleName;
|
||||
return vehicleName != null ? vehicleName.replace(":", "-") : vehicleName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,7 +12,9 @@
|
||||
*/
|
||||
package org.openhab.binding.evcc.internal.api.dto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@ -219,7 +221,12 @@ public class Result {
|
||||
}
|
||||
|
||||
public Map<String, Vehicle> getVehicles() {
|
||||
return vehicles;
|
||||
Map<String, Vehicle> correctedMap = new HashMap<>();
|
||||
for (Entry<String, Vehicle> entry : vehicles.entrySet()) {
|
||||
// The key from the vehicles map is used as uid, so it should not contain semicolons.
|
||||
correctedMap.put(entry.getKey().replace(":", "-"), entry.getValue());
|
||||
}
|
||||
return correctedMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user