Vehicles: make identifier matching case insensitive
This commit is contained in:
parent
e79505e602
commit
c16f473029
1 changed files with 6 additions and 4 deletions
|
|
@ -19,7 +19,6 @@ import (
|
|||
"github.com/evcc-io/evcc/provider"
|
||||
"github.com/evcc-io/evcc/push"
|
||||
"github.com/evcc-io/evcc/util"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
evbus "github.com/asaskevich/EventBus"
|
||||
"github.com/avast/retry-go/v3"
|
||||
|
|
@ -816,15 +815,18 @@ func (lp *LoadPoint) selectVehicleByID(id string) api.Vehicle {
|
|||
|
||||
// find exact match
|
||||
for _, vehicle := range vehicles {
|
||||
if slices.Contains(vehicle.Identifiers(), id) {
|
||||
return vehicle
|
||||
for _, vid := range vehicle.Identifiers() {
|
||||
if strings.EqualFold(id, vid) {
|
||||
return vehicle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// find placeholder match
|
||||
for _, vehicle := range vehicles {
|
||||
for _, vid := range vehicle.Identifiers() {
|
||||
re, err := regexp.Compile(strings.ReplaceAll(vid, "*", ".*?"))
|
||||
// case insensitive match
|
||||
re, err := regexp.Compile("(?i)" + strings.ReplaceAll(vid, "*", ".*?"))
|
||||
if err != nil {
|
||||
lp.log.ERROR.Printf("vehicle id: %v", err)
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue