More changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 23s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 23s
This commit is contained in:
35
vehicle.go
35
vehicle.go
@ -685,7 +685,7 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
v.parseDoor("Door", "Position", typeOfS.Field(i).Name, val.Field(i).Interface())
|
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") {
|
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") {
|
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())
|
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.TrimPrefix(name, prefix)
|
||||||
pos = strings.TrimSuffix(pos, suffix)
|
pos = strings.TrimSuffix(pos, suffix)
|
||||||
submatchall := re.FindAllString(pos, -1)
|
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 {
|
if door, ok := v.Doors[pos]; ok {
|
||||||
door.Status = value.(string)
|
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 .
|
// parseWindow .
|
||||||
func (v *Vehicle) parseWindow(prefix, suffix, name string, value any) {
|
func (v *Vehicle) parseWindow(prefix, suffix, name string, value any) {
|
||||||
re := regexp.MustCompile(`[A-Z][^A-Z]*`)
|
re := regexp.MustCompile(`[A-Z][^A-Z]*`)
|
||||||
pos := strings.TrimPrefix(name, prefix)
|
pos := strings.TrimPrefix(name, prefix)
|
||||||
pos = strings.TrimSuffix(pos, suffix)
|
pos = strings.TrimSuffix(pos, suffix)
|
||||||
submatchall := re.FindAllString(pos, -1)
|
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 {
|
if window, ok := v.Windows[pos]; ok {
|
||||||
window.Status = value.(string)
|
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.TrimPrefix(name, prefix)
|
||||||
pos = strings.TrimSuffix(pos, suffix)
|
pos = strings.TrimSuffix(pos, suffix)
|
||||||
submatchall := re.FindAllString(pos, -1)
|
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 {
|
if tire, ok := v.Tires[pos]; ok {
|
||||||
tire.PressurePsi = value.(string)
|
tire.PressurePsi = value.(string)
|
||||||
|
Reference in New Issue
Block a user