More changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 23s

This commit is contained in:
2025-06-03 19:40:07 -04:00
parent e3dc297ad1
commit 41b7e0184c

View File

@ -685,7 +685,7 @@ func (v *Vehicle) GetVehicleCondition() {
v.parseDoor("Door", "Position", typeOfS.Field(i).Name, val.Field(i).Interface())
}
if strings.HasPrefix(typeOfS.Field(i).Name, "Door") && strings.HasSuffix(typeOfS.Field(i).Name, "LockStatus") {
v.parseDoor("Door", "LockStatus", typeOfS.Field(i).Name, val.Field(i).Interface())
v.parseLock("Door", "LockStatus", typeOfS.Field(i).Name, val.Field(i).Interface())
}
if strings.HasPrefix(typeOfS.Field(i).Name, "Window") && strings.HasSuffix(typeOfS.Field(i).Name, "Status") {
v.parseWindow("Window", "Status", typeOfS.Field(i).Name, val.Field(i).Interface())
@ -794,7 +794,7 @@ func (v *Vehicle) parseDoor(prefix, suffix, name string, value any) {
pos := strings.TrimPrefix(name, prefix)
pos = strings.TrimSuffix(pos, suffix)
submatchall := re.FindAllString(pos, -1)
v.client.logger.Debug("VEHICLE COND", "key", name, "value", value, "number", len(submatchall))
// v.client.logger.Debug("VEHICLE COND", "key", name, "value", value, "number", len(submatchall))
if door, ok := v.Doors[pos]; ok {
door.Status = value.(string)
@ -816,13 +816,40 @@ func (v *Vehicle) parseDoor(prefix, suffix, name string, value any) {
}
}
// parseLock .
func (v *Vehicle) parseLock(prefix, suffix, name string, value any) {
re := regexp.MustCompile(`[A-Z][^A-Z]*`)
pos := strings.TrimPrefix(name, prefix)
pos = strings.TrimSuffix(pos, suffix)
submatchall := re.FindAllString(pos, -1)
// v.client.logger.Debug("VEHICLE COND", "key", name, "value", value, "number", len(submatchall))
if door, ok := v.Doors[pos]; ok {
door.Lock = value.(string)
} else {
door.Lock = value.(string)
door.Updated = time.Now()
v.Doors[pos] = Door{
Position: submatchall[0],
Lock: value.(string),
Updated: time.Now(),
}
if len(submatchall) >= 2 {
if d, ok := v.Doors[pos]; ok {
d.SubPosition = submatchall[1]
v.Doors[pos] = d
}
}
}
}
// parseWindow .
func (v *Vehicle) parseWindow(prefix, suffix, name string, value any) {
re := regexp.MustCompile(`[A-Z][^A-Z]*`)
pos := strings.TrimPrefix(name, prefix)
pos = strings.TrimSuffix(pos, suffix)
submatchall := re.FindAllString(pos, -1)
v.client.logger.Debug("VEHICLE COND", "key", name, "data", value, "number", len(submatchall))
// v.client.logger.Debug("VEHICLE COND", "key", name, "data", value, "number", len(submatchall))
if window, ok := v.Windows[pos]; ok {
window.Status = value.(string)
@ -850,7 +877,7 @@ func (v *Vehicle) parseTire(prefix, suffix, name string, value any) {
pos := strings.TrimPrefix(name, prefix)
pos = strings.TrimSuffix(pos, suffix)
submatchall := re.FindAllString(pos, -1)
v.client.logger.Debug("VEHICLE COND", "key", name, "data", value, "number", len(submatchall))
// v.client.logger.Debug("VEHICLE COND", "key", name, "data", value, "number", len(submatchall))
if tire, ok := v.Tires[pos]; ok {
tire.PressurePsi = value.(string)