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"
|
WindowFrontRightStatus string `json:"windowFrontRightStatus"` // + "CLOSE"
|
||||||
WindowRearLeftStatus string `json:"windowRearLeftStatus"` // + "CLOSE"
|
WindowRearLeftStatus string `json:"windowRearLeftStatus"` // + "CLOSE"
|
||||||
WindowRearRightStatus string `json:"windowRearRightStatus"` // + "CLOSE"
|
WindowRearRightStatus string `json:"windowRearRightStatus"` // + "CLOSE"
|
||||||
WindowSunroofStatus string `json:"windowSunroofStatus"` // + "UNKNOWN"
|
WindowSunroofStatus string `json:"windowSunroofStatus"` // + "CLOSE"
|
||||||
DoorBootPosition string `json:"doorBootPosition"` // CLOSED
|
DoorBootPosition string `json:"doorBootPosition"` // CLOSED
|
||||||
DoorEngineHoodPosition string `json:"doorEngineHoodPosition"` // CLOSED
|
DoorEngineHoodPosition string `json:"doorEngineHoodPosition"` // CLOSED
|
||||||
DoorFrontLeftPosition string `json:"doorFrontLeftPosition"` // CLOSED
|
DoorFrontLeftPosition string `json:"doorFrontLeftPosition"` // CLOSED
|
||||||
|
88
vehicle.go
88
vehicle.go
@ -175,6 +175,12 @@ func (v *Vehicle) String() string {
|
|||||||
// fmt.Printf("%d >> %+v\n", i+1, d)
|
// 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"
|
vString += "=== FEATURES =====================\n"
|
||||||
for i, f := range v.Features {
|
for i, f := range v.Features {
|
||||||
if !strings.HasSuffix(f, "_MIL") {
|
if !strings.HasSuffix(f, "_MIL") {
|
||||||
@ -618,7 +624,9 @@ func (v *Vehicle) GetVehicleStatus() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
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))
|
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
||||||
|
|
||||||
if window, ok := v.Windows[submatchall[0]+submatchall[1]]; ok {
|
if window, ok := v.Windows[submatchall[0]+submatchall[1]]; ok {
|
||||||
@ -629,18 +637,41 @@ func (v *Vehicle) GetVehicleStatus() {
|
|||||||
window.Updated = time.Now()
|
window.Updated = time.Now()
|
||||||
v.Windows[submatchall[0]+submatchall[1]] = Window{
|
v.Windows[submatchall[0]+submatchall[1]] = Window{
|
||||||
Position: submatchall[0],
|
Position: submatchall[0],
|
||||||
SubPosition: submatchall[1],
|
|
||||||
Status: child.Data().(string),
|
Status: child.Data().(string),
|
||||||
Updated: time.Now(),
|
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, "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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,7 +796,9 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
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))
|
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
||||||
|
|
||||||
if window, ok := v.Windows[submatchall[0]+submatchall[1]]; ok {
|
if window, ok := v.Windows[submatchall[0]+submatchall[1]]; ok {
|
||||||
@ -776,18 +809,41 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
window.Updated = time.Now()
|
window.Updated = time.Now()
|
||||||
v.Windows[submatchall[0]+submatchall[1]] = Window{
|
v.Windows[submatchall[0]+submatchall[1]] = Window{
|
||||||
Position: submatchall[0],
|
Position: submatchall[0],
|
||||||
SubPosition: submatchall[1],
|
|
||||||
Status: child.Data().(string),
|
Status: child.Data().(string),
|
||||||
Updated: time.Now(),
|
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, "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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
v.Updated = time.Now()
|
v.Updated = time.Now()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user