Added parsing way of tires
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:
@ -181,7 +181,7 @@ type VehicleStatus struct {
|
||||
WindowFrontRightStatus string `json:"windowFrontRightStatus"` // + "CLOSE"
|
||||
WindowRearLeftStatus string `json:"windowRearLeftStatus"` // + "CLOSE"
|
||||
WindowRearRightStatus string `json:"windowRearRightStatus"` // + "CLOSE"
|
||||
WindowSunroofStatus string `json:"windowSunroofStatus"` // + "UNKNOWN"
|
||||
WindowSunroofStatus string `json:"windowSunroofStatus"` // + "CLOSE"
|
||||
DoorBootPosition string `json:"doorBootPosition"` // CLOSED
|
||||
DoorEngineHoodPosition string `json:"doorEngineHoodPosition"` // CLOSED
|
||||
DoorFrontLeftPosition string `json:"doorFrontLeftPosition"` // CLOSED
|
||||
|
100
vehicle.go
100
vehicle.go
@ -175,6 +175,12 @@ func (v *Vehicle) String() string {
|
||||
// fmt.Printf("%d >> %+v\n", i+1, d)
|
||||
}
|
||||
|
||||
vString += "=== TIRES =====================\n"
|
||||
for k, v := range v.Tires {
|
||||
vString += fmt.Sprintf("%s >> %+v\n", k, v)
|
||||
// fmt.Printf("%d >> %+v\n", i+1, d)
|
||||
}
|
||||
|
||||
vString += "=== FEATURES =====================\n"
|
||||
for i, f := range v.Features {
|
||||
if !strings.HasSuffix(f, "_MIL") {
|
||||
@ -618,7 +624,9 @@ func (v *Vehicle) GetVehicleStatus() {
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
||||
submatchall := re.FindAllString(key, -1)
|
||||
pos := strings.TrimPrefix(key, "door")
|
||||
pos = strings.TrimSuffix(pos, "Status")
|
||||
submatchall := re.FindAllString(pos, -1)
|
||||
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
||||
|
||||
if window, ok := v.Windows[submatchall[0]+submatchall[1]]; ok {
|
||||
@ -628,19 +636,42 @@ func (v *Vehicle) GetVehicleStatus() {
|
||||
window.Status = child.Data().(string)
|
||||
window.Updated = time.Now()
|
||||
v.Windows[submatchall[0]+submatchall[1]] = Window{
|
||||
Position: submatchall[0],
|
||||
SubPosition: submatchall[1],
|
||||
Status: child.Data().(string),
|
||||
Updated: time.Now(),
|
||||
Position: submatchall[0],
|
||||
Status: child.Data().(string),
|
||||
Updated: time.Now(),
|
||||
}
|
||||
if len(submatchall) >= 2 {
|
||||
if w, ok := v.Windows[pos]; ok {
|
||||
w.SubPosition = submatchall[1]
|
||||
v.Windows[pos] = w
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(key, "tire") && !strings.HasSuffix(key, "Psi") {
|
||||
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data())
|
||||
// submatchall := re.FindAllString(key, -1)
|
||||
// for _, element := range submatchall {
|
||||
// fmt.Println(element)
|
||||
// }
|
||||
if strings.HasPrefix(key, "tirePressure") && !strings.HasSuffix(key, "Psi") {
|
||||
pos := strings.TrimPrefix(key, "tirePressure")
|
||||
pos = strings.TrimSuffix(pos, "Psi")
|
||||
submatchall := re.FindAllString(pos, -1)
|
||||
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
||||
|
||||
if tire, ok := v.Tires[submatchall[0]+submatchall[1]]; ok {
|
||||
tire.PressurePsi = child.Data().(int)
|
||||
tire.Updated = time.Now()
|
||||
} else {
|
||||
tire.PressurePsi = child.Data().(int)
|
||||
tire.Updated = time.Now()
|
||||
v.Tires[submatchall[0]+submatchall[1]] = Tire{
|
||||
Position: submatchall[0],
|
||||
PressurePsi: child.Data().(int),
|
||||
Updated: time.Now(),
|
||||
}
|
||||
if len(submatchall) >= 2 {
|
||||
if t, ok := v.Tires[pos]; ok {
|
||||
t.SubPosition = submatchall[1]
|
||||
v.Tires[pos] = t
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -765,7 +796,9 @@ func (v *Vehicle) GetVehicleCondition() {
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
||||
submatchall := re.FindAllString(key, -1)
|
||||
pos := strings.TrimPrefix(key, "door")
|
||||
pos = strings.TrimSuffix(pos, "Status")
|
||||
submatchall := re.FindAllString(pos, -1)
|
||||
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
||||
|
||||
if window, ok := v.Windows[submatchall[0]+submatchall[1]]; ok {
|
||||
@ -775,19 +808,42 @@ func (v *Vehicle) GetVehicleCondition() {
|
||||
window.Status = child.Data().(string)
|
||||
window.Updated = time.Now()
|
||||
v.Windows[submatchall[0]+submatchall[1]] = Window{
|
||||
Position: submatchall[0],
|
||||
SubPosition: submatchall[1],
|
||||
Status: child.Data().(string),
|
||||
Updated: time.Now(),
|
||||
Position: submatchall[0],
|
||||
Status: child.Data().(string),
|
||||
Updated: time.Now(),
|
||||
}
|
||||
if len(submatchall) >= 2 {
|
||||
if w, ok := v.Windows[pos]; ok {
|
||||
w.SubPosition = submatchall[1]
|
||||
v.Windows[pos] = w
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(key, "tire") && !strings.HasSuffix(key, "Unit") {
|
||||
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data())
|
||||
// submatchall := re.FindAllString(key, -1)
|
||||
// for _, element := range submatchall {
|
||||
// fmt.Println(element)
|
||||
// }
|
||||
if strings.HasPrefix(key, "tirePressure") && !strings.HasSuffix(key, "Psi") {
|
||||
pos := strings.TrimPrefix(key, "tirePressure")
|
||||
pos = strings.TrimSuffix(pos, "Psi")
|
||||
submatchall := re.FindAllString(pos, -1)
|
||||
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
||||
|
||||
if tire, ok := v.Tires[submatchall[0]+submatchall[1]]; ok {
|
||||
tire.PressurePsi = child.Data().(int)
|
||||
tire.Updated = time.Now()
|
||||
} else {
|
||||
tire.PressurePsi = child.Data().(int)
|
||||
tire.Updated = time.Now()
|
||||
v.Tires[submatchall[0]+submatchall[1]] = Tire{
|
||||
Position: submatchall[0],
|
||||
PressurePsi: child.Data().(int),
|
||||
Updated: time.Now(),
|
||||
}
|
||||
if len(submatchall) >= 2 {
|
||||
if t, ok := v.Tires[pos]; ok {
|
||||
t.SubPosition = submatchall[1]
|
||||
v.Tires[pos] = t
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
v.Updated = time.Now()
|
||||
}
|
||||
|
Reference in New Issue
Block a user