More changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 25s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 25s
This commit is contained in:
44
vehicle.go
44
vehicle.go
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -478,23 +479,23 @@ func (v *Vehicle) GetClimatePresets() {
|
||||
for _, cp := range cProfiles {
|
||||
if v.isEV() && cp.VehicleType == "phev" {
|
||||
if _, ok := v.ClimateProfiles[cp.PresetType+strings.ReplaceAll(cp.Name, " ", "")]; ok {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
v.ClimateProfiles[cp.PresetType+strings.ReplaceAll(cp.Name, " ", "")] = cp
|
||||
} else {
|
||||
if _, ok := v.ClimateProfiles[cp.PresetType+strings.ReplaceAll(cp.Name, " ", "")]; ok {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
v.ClimateProfiles[cp.PresetType+strings.ReplaceAll(cp.Name, " ", "")] = cp
|
||||
} else {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
v.ClimateProfiles[cp.PresetType+strings.ReplaceAll(cp.Name, " ", "")] = cp
|
||||
}
|
||||
}
|
||||
}
|
||||
if !v.isEV() && cp.VehicleType == "gas" {
|
||||
if _, ok := v.ClimateProfiles[cp.PresetType+strings.ReplaceAll(cp.Name, " ", "")]; ok {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
v.ClimateProfiles[cp.PresetType+strings.ReplaceAll(cp.Name, " ", "")] = cp
|
||||
} else {
|
||||
if _, ok := v.ClimateProfiles[cp.PresetType+strings.ReplaceAll(cp.Name, " ", "")]; ok {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
v.ClimateProfiles[cp.PresetType+strings.ReplaceAll(cp.Name, " ", "")] = cp
|
||||
} else {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
v.ClimateProfiles[cp.PresetType+strings.ReplaceAll(cp.Name, " ", "")] = cp
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -625,17 +626,9 @@ func (v *Vehicle) GetVehicleStatus() {
|
||||
val := reflect.ValueOf(vs)
|
||||
typeOfS := val.Type()
|
||||
|
||||
badValues := []any{"NOT_EQUIPPED", "UNKNOWN", "None", "16383", "65535", "-64", "", 0, float64(0), nil}
|
||||
for i := 0; i < val.NumField(); i++ {
|
||||
if val.Field(i).Interface() == "NOT_EQUIPPED" ||
|
||||
val.Field(i).Interface() == "UNKNOWN" ||
|
||||
val.Field(i).Interface() == "None" ||
|
||||
val.Field(i).Interface() == "16383" ||
|
||||
val.Field(i).Interface() == "65535" ||
|
||||
val.Field(i).Interface() == "-64" ||
|
||||
val.Field(i).Interface() == "" ||
|
||||
val.Field(i).Interface() == 0 ||
|
||||
val.Field(i).Interface() == float64(0) ||
|
||||
val.Field(i).Interface() == nil {
|
||||
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())
|
||||
@ -682,17 +675,9 @@ func (v *Vehicle) GetVehicleCondition() {
|
||||
val := reflect.ValueOf(vc)
|
||||
typeOfS := val.Type()
|
||||
|
||||
badValues := []any{"NOT_EQUIPPED", "UNKNOWN", "None", "16383", "65535", "-64", "", 0, float64(0), nil}
|
||||
for i := 0; i < val.NumField(); i++ {
|
||||
if val.Field(i).Interface() == "NOT_EQUIPPED" ||
|
||||
val.Field(i).Interface() == "UNKNOWN" ||
|
||||
val.Field(i).Interface() == "None" ||
|
||||
val.Field(i).Interface() == "16383" ||
|
||||
val.Field(i).Interface() == "65535" ||
|
||||
val.Field(i).Interface() == "-64" ||
|
||||
val.Field(i).Interface() == "" ||
|
||||
val.Field(i).Interface() == 0 ||
|
||||
val.Field(i).Interface() == float64(0) ||
|
||||
val.Field(i).Interface() == nil {
|
||||
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())
|
||||
@ -731,17 +716,18 @@ func (v *Vehicle) GetVehicleHealth() {
|
||||
v.client.logger.Error("error while parsing json", "request", "GetVehicleHealth", "error", err.Error())
|
||||
}
|
||||
v.client.logger.Debug("http request output", "request", "GetVehicleHealth", "vehicle health", vh)
|
||||
// TODO: Loop over all the Vehicle Health Items
|
||||
|
||||
for i, vhi := range vh.VehicleHealthItems {
|
||||
v.client.logger.Debug("vehicle health item", "id", i, "item", vhi)
|
||||
if vhi.IsTrouble {
|
||||
// if contains(troubles, vhi.FeatureCode) {}
|
||||
if _, ok := troubles[vhi.FeatureCode]; ok {
|
||||
v.client.logger.Debug("found troubled vehicle health item", "id", i, "item", vhi)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// GetFeaturesList .
|
||||
|
Reference in New Issue
Block a user