More changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 24s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 24s
This commit is contained in:
50
vehicle.go
50
vehicle.go
@ -628,10 +628,10 @@ func (v *Vehicle) GetVehicleStatus() {
|
||||
|
||||
// for i := 0; i < val.NumField(); i++ {
|
||||
for i := range val.NumField() {
|
||||
v.client.logger.Debug("vehicle status >> parsing a car part", "field", typeOfS.Field(i).Name, "value", val.Field(i).Interface(), "type", val.Field(i).Type())
|
||||
if slices.Contains(badValues, val.Field(i).Interface()) {
|
||||
continue
|
||||
} else {
|
||||
// v.client.logger.Debug("parsing a car part", "field", typeOfS.Field(i).Name, "value", val.Field(i).Interface(), "type", val.Field(i).Type())
|
||||
if strings.HasPrefix(typeOfS.Field(i).Name, "Door") && strings.HasSuffix(typeOfS.Field(i).Name, "Position") {
|
||||
v.parseDoor("Door", "Position", typeOfS.Field(i).Name, val.Field(i).Interface())
|
||||
}
|
||||
@ -642,7 +642,7 @@ func (v *Vehicle) GetVehicleStatus() {
|
||||
v.parseWindow("Window", "Status", typeOfS.Field(i).Name, val.Field(i).Interface())
|
||||
}
|
||||
if strings.HasPrefix(typeOfS.Field(i).Name, "TirePressure") && strings.HasSuffix(typeOfS.Field(i).Name, "Psi") {
|
||||
v.parseTire("TirePressure", "Psi", typeOfS.Field(i).Name, val.Field(i).Interface())
|
||||
v.parseTirePsi("TirePressure", "Psi", typeOfS.Field(i).Name, val.Field(i).Interface())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -677,10 +677,10 @@ func (v *Vehicle) GetVehicleCondition() {
|
||||
|
||||
// for i := 0; i < val.NumField(); i++ {
|
||||
for i := range val.NumField() {
|
||||
v.client.logger.Debug("vehicle condition >> parsing a car part", "field", typeOfS.Field(i).Name, "value", val.Field(i).Interface(), "type", val.Field(i).Type())
|
||||
if slices.Contains(badValues, val.Field(i).Interface()) {
|
||||
continue
|
||||
} else {
|
||||
// v.client.logger.Debug("parsing a car part", "field", typeOfS.Field(i).Name, "value", val.Field(i).Interface(), "type", val.Field(i).Type())
|
||||
if strings.HasPrefix(typeOfS.Field(i).Name, "Door") && strings.HasSuffix(typeOfS.Field(i).Name, "Position") {
|
||||
v.parseDoor("Door", "Position", typeOfS.Field(i).Name, val.Field(i).Interface())
|
||||
}
|
||||
@ -690,9 +690,9 @@ func (v *Vehicle) GetVehicleCondition() {
|
||||
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())
|
||||
}
|
||||
// if strings.HasPrefix(typeOfS.Field(i).Name, "tirePressure") {
|
||||
// v.parseTire("tirePressure", "", typeOfS.Field(i).Name, val.Field(i).Interface())
|
||||
// }
|
||||
if strings.HasPrefix(typeOfS.Field(i).Name, "TirePressure") {
|
||||
v.parseTire("TirePressure", "", typeOfS.Field(i).Name, val.Field(i).Interface())
|
||||
}
|
||||
}
|
||||
}
|
||||
v.Updated = time.Now()
|
||||
@ -732,11 +732,11 @@ func (v *Vehicle) GetVehicleHealth() {
|
||||
|
||||
// GetFeaturesList .
|
||||
func (v *Vehicle) GetFeaturesList() {
|
||||
for i, f := range v.Features {
|
||||
for _, f := range v.Features {
|
||||
if _, ok := features[f]; ok {
|
||||
fmt.Printf("%d >> %s // %s\n", i+1, f, features[f])
|
||||
v.client.logger.Debug("vehicle features", "id", f, "feature", features[f])
|
||||
} else {
|
||||
fmt.Printf("%d >> %s\n", i+1, f)
|
||||
v.client.logger.Debug("vehicle features", "id", f)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -871,8 +871,8 @@ func (v *Vehicle) parseWindow(prefix, suffix, name string, value any) {
|
||||
}
|
||||
}
|
||||
|
||||
// parseTire .
|
||||
func (v *Vehicle) parseTire(prefix, suffix, name string, value any) {
|
||||
// parseTirePsi .
|
||||
func (v *Vehicle) parseTirePsi(prefix, suffix, name string, value any) {
|
||||
re := regexp.MustCompile(`[A-Z][^A-Z]*`)
|
||||
pos := strings.TrimPrefix(name, prefix)
|
||||
pos = strings.TrimSuffix(pos, suffix)
|
||||
@ -899,6 +899,34 @@ func (v *Vehicle) parseTire(prefix, suffix, name string, value any) {
|
||||
}
|
||||
}
|
||||
|
||||
// parseTire .
|
||||
func (v *Vehicle) parseTire(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))
|
||||
|
||||
if tire, ok := v.Tires[pos]; ok {
|
||||
tire.Pressure = value.(int)
|
||||
tire.Updated = time.Now()
|
||||
} else {
|
||||
tire.Pressure = value.(int)
|
||||
tire.Updated = time.Now()
|
||||
v.Tires[pos] = Tire{
|
||||
Position: submatchall[0],
|
||||
Pressure: value.(int),
|
||||
Updated: time.Now(),
|
||||
}
|
||||
if len(submatchall) >= 2 {
|
||||
if t, ok := v.Tires[pos]; ok {
|
||||
t.SubPosition = submatchall[1]
|
||||
v.Tires[pos] = t
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// // getRemoteStartStatus .
|
||||
// // Get whether the specified VIN has remote engine start service available.
|
||||
// func (v *Vehicle) getRemoteStartStatus() bool {
|
||||
|
Reference in New Issue
Block a user