[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:
lsiepel 2024-09-09 18:56:55 +02:00 committed by GitHub
parent 110fd9b1ca
commit 16a6853efb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View File

@ -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) {

View File

@ -271,7 +271,7 @@ public class Loadpoint {
* @return vehicle's title/name
*/
public String getVehicleName() {
return vehicleName;
return vehicleName != null ? vehicleName.replace(":", "-") : vehicleName;
}
/**

View File

@ -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;
}
/**