Testing Climate Quick Presets parsing
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:
32
vehicle.go
32
vehicle.go
@ -438,25 +438,33 @@ func (v *Vehicle) GetClimateQuickPresets() {
|
||||
|
||||
respParsed, err := gabs.ParseJSON(resp)
|
||||
if err != nil {
|
||||
v.client.logger.Error("error while parsing json", "request", "GetClimateQuickPresets", "error", err.Error())
|
||||
v.client.logger.Error("error while parsing http output json", "request", "GetClimateQuickPresets", "error", err.Error())
|
||||
}
|
||||
v.client.logger.Debug("CLIMATE SETTINGS OUTPUT", "body", respParsed)
|
||||
|
||||
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPING DATA IN DATA FIELD
|
||||
data, ok := respParsed.Path("data").Data().(string)
|
||||
|
||||
// rawIn := json.RawMessage(in)
|
||||
// bytes, err := rawIn.MarshalJSON()
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
|
||||
// value == string, ok == false
|
||||
if !ok {
|
||||
// TODO: Work with errorCode
|
||||
panic(data)
|
||||
v.client.logger.Error("error while parsing data json", "request", "GetClimateQuickPresets", "error", err.Error())
|
||||
}
|
||||
|
||||
cProfiles := []ClimateProfile{}
|
||||
err = json.Unmarshal([]byte(data), &cProfiles)
|
||||
v.client.logger.Debug("climate quick presets", "data", data)
|
||||
|
||||
if err != nil {
|
||||
v.client.logger.Error("error while parsing climate quick presets json", "request", "GetClimateQuickPresets", "error", err.Error())
|
||||
}
|
||||
|
||||
if len(cProfiles) > 0 {
|
||||
for _, cp := range cProfiles {
|
||||
if _, ok := v.ClimateProfiles[cp.PresetType+cp.Name]; ok {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
} else {
|
||||
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
|
||||
}
|
||||
}
|
||||
}
|
||||
v.client.logger.Debug("PRESETS", "output", data)
|
||||
} else {
|
||||
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||
}
|
||||
|
Reference in New Issue
Block a user